|
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 EventsTouch 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);
});
});
|
► Sign in to add a comment
I'm pretty sure console.log(info.orientation); // landscape or portrait should be console.log(info.orientation); // landscape or profile
Is there a way to force rotation to landscape?
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 :)
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); } }); });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
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).
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,
How can I know what button fired the animation event?
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!