My favorites | Sign in
Logo
                
Search
for
Updated Oct 13, 2009 by davidcolbykaneda
CallbackEvents  
Built-in Triggers/Events in jQTouch.

Events must be added after document has loaded. For this, we use the jQuery .ready() method.

Page Animations

    $(document).ready(function(e){
        $('#portfolio').bind('pageAnimationEnd', function(event, info){
            if (info.direction == 'in') loadWorks();
        })
    });

Orientation Changes

    $(function(){
        $('body').bind('turn', function(event, info){
              console.log(info.orientation); // landscape or profile
        });
        
    });

Touch Events

Touch events will only trigger on items which are initialized, either automatically via the initialization function (initializeTouch: 'a, .touchable') or manually ( $('#mydiv').addTouchEvents()).

    $(function(){
        $('#swipeme').bind('swipe', function(event, info){
              console.log(info.direction);
        });
    });

You can also use the jQuery-style event shortcut, like:

    $(function(){
        $('#swipeme').swipe( function(event, info){
              console.log(info.direction);
        });
    });

Comment by i.chris.jacob, Oct 12, 2009

I'm pretty sure console.log(info.orientation); // landscape or portrait should be console.log(info.orientation); // landscape or profile

Comment by stevegabrio, Oct 19, 2009

Is there a way to force rotation to landscape?

Comment by paul.vudmaska, Nov 05, 2009

I wanted to be able to attach an onsubmit to forms, here is how I did in in jqtouch.js about line 472.

function submitForm(e, callback){

var $form = (typeof(e)==='string') ? $(e) : $(e.target);
if ($form.length && $form.is(jQTSettings.formSelector) && $form.attr('action')) {

var onsubmit = false;
if($form.attr('onsubmit')){onsubmit = (new Function($form.attr('onsubmit')))()};
if(onsubmit)
{
showPageByHref($form.attr('action'), {
        data: $form.serialize(),
        method: $form.attr('method') || "POST",
        animation: animations[0] || null,
        callback: callback
    });
}

   return false;
}
return true;
}

This allows you to use onsubmit like you regularly would. Note that you can not however use arguments ( which I usually use something like onsubmit="return validate(this)".

Not sure this is the best way to do it but this worked and I thought I'd share :)

Comment by i.dream.scape, Dec 09, 2009

paul.vudmaska,

You can just use the jQuery form submit event handler. The jqTouch submit is attached to the html body, so the submit event on the form will be called first. If you wish to stop the submit from going through, just use event.Propagation() or event.stopImmediatePropagation()

basic example:

$(function()
{
    $('#theFormId').submit(function(e)
    {
        validateFields();
        if (error)
        {
            e.stopImmediatePropagation();
            alert(error);
        }
    });
});
Comment by ash...@ls12style.co.uk, Jan 18, 2010

im trying to create a login form using jqtouch and im getting nowhere. ive created the form, but i cant figure out how to make the form submit via ajax and read the returned JSON data.

any pointers would be great. Ive been looking at the source but am clueless :P

thanks

Comment by ed.m.dudley, Jan 21, 2010

Answering the question about creating a logon form, check this out. https://peepcode.com/products/jqtouch It's not free but I highly recommend it and they actually do exactly what your asking (login form with JSON).

Comment by shrutikanda, Feb 02, 2010

using jqtouch how one can call sever side events? as i have a form with button , which has sever side button_click event , but when i click that button it gets me to nowhere. Please advice, Thanks,

Comment by cedric.dugas, Feb 27, 2010

How can I know what button fired the animation event?

Comment by stu...@swim.com.au, Mar 18 (3 days ago)

how would you go about forwarding the user to a new page (loaded via the ajax method) when they tip the phone to landscape? I want to achieve a similar function to the iphones native functionality where in ipod mode if you tip the phone to landscape you get coverflow.

basically every time the user changes to landscape mode i want to show my portfolio, then when they turn back to portrait it goes back to index page.

any ideas?

this really is fantastic work by the way!


Sign in to add a comment
Powered by Google Project Hosting