|
PublicObject
Manipulating jQTouch directly with Javascript
Featured Public FunctionsjQTouch returns a public object when initialized, which can be assigned to a variable (in this case, the variable name is "jQT"): <script>
var jQT = new $.jQTouch();
</script>This public variable has several functions which allow you to directly manipulate jQTouch via Javascript. It is recommended you call these function after the document.ready event. These public functions are: goTo( pageid: string, animation: string )Forces jQTouch to animate to a new page (pageid), with the listed animation. Example: jQT.goTo('#newpage', 'flip'); goBack( to:object )Forces jQTouch to go back to a certain page in the history. You can pass a specific page ID, a number of pages to go back, or nothing to go back one page. If the specified page can not be found, jQTouch will go back one page by default. Example: jQT.goBack(2); // Goes back 2 pages in history
jQT.goBack('#home'); // Goes to #home as long as it's in history
jQT.goBack(); // Goes back 1 page in historyaddAnimation( animation:Object )Allows the author to dynamically add custom page animations. For more information, see Animations. Example: jQT.addAnimation({ name: 'reveal', selector: '.revealme' });
|
I'm using jQT.goTo('#newpage', 'flip') to bring up a new page but whenever I hit back on that page (with the standard jqtouch back button in the toolbar) nothing happens. Looking in Firebug I get an error of "No pages in history." that looks like it happens on the goBack function.
Yes, I am experiencing the same problem here. It seems that the goTo function does not update the history stack. Anyone know of a workaround?
Is there any way to remove a given page from the history? I have a situation where;
Is there any programmatic way to remove page_B from the history when I transition? Possible in the pageAnimationEnd callback or similar?
Hi, Further to the comments above by maralbjo and above, I notice on the console that there is an 'unknown hash change' at line 408 of jqtouch.js and then a loop logging endlessly 'No pages in history' at line 237. This is only the case if you press the browser back key on the very first (entry) page. It works on all subsequent pages, just not the first one.
The goTo function kind of messes up the history stack a bit. As an alternative, I have had some success with simulating a user press on the back button instead. In order to do that, one must give the back button an ID in order to target it with JQuery. Giving the back button an idea feels odd, but it works despite an error from the jqtouch.js saying: $referrer is not defined.
maralbjo, when you say give the back button an id, can you elaborate? You mean the browser back button? How do you do this?
I'm wondering where can I add code ((#inputfield).focus()) after automatics goTo. If I write the button click action, I write the goTo and AFTER I write the .focus, but after an automatic goTo where can I put the focus code? If I put it on the onclick in the menu action, is executed before the goTo and after the div page get the focus, the input field lost focus...
how to redirect link to a new page ?
above code is not understandable for me..
webmas...@town2web.com Ar you not best attaching the focus operation to the end of animation callback? I suspect it need to be done as the last thing that happens, otherwise you can't count on the page being 'settled', as you have discovered.
Glenn
@cypherlou666: Often I find that I want to send the user back the previous screen after he has performed some action. If I use the goTo-function, that leads to unwanted history stacking, but using this approach works fine:
<div class="toolbar">
</div> <div> (main content) </div>// Send the user back instead of using goTo (using JQuery) $("#backToAdvanced").click();
(That didn't quite format as I intended, sorry)
Although (@cypherlou666), you should be ware of issue 102 that in my opinion renders this functionality obsolete. A fix/workaroud would be warmly appreciated.
http://code.google.com/p/jqtouch/issues/detail?id=102#makechanges
Is there a way to create a link (normally something like <a href="mailto:my@email.com">Email</a>) to send a file, with JQTouch/Javascript?
ricky.dejong It clearly states in the i-phone web-app developers documentation that this is not a supported feature of the device. If you/anyone else knows to the contrary then I would be interested to hear.
glenn
Trying to figure out how to disable a link if it exists on the page the link is linking to. Anyone know how to do this? Or even how to return the name or ID of the current page?
I have a global toolbar and say you click "Home" while you're already on the home page, the app goes nuts and gives you a blank page.
Help me i need examples of the function goTo
is there a way to find out what page are you currently in?
<is there a way to find out what page are you currently in?>
currentpage = $('.current').attr('id');
hi, someone know if is possible send goTo another page html or jsp? many thanks!
jimmybrooks.com, i was running into the same issue. The workaround that i found was to add in an if statement that checks to see if the toPage is equal to the fromPage. A rewrite for the animate pages function is below. Replace it with the one at line 332 in jqtouch.js. Hope this helps.
Is it possible to load a new page and go to a specified id?
Ex: $('.class').click(function(){
});@ sirmark Can you dubblecheck your function? This has lots of syntax issues in it. Lots of { are closed although they where not opened.
I am looking for a way for people to pass jqTouch links around and have them work as one would expect them to. For example: jqTouch follows www.mysite.com/ContactUs?.html and loads the ContactUs? form on to the screen. It then sets the page URL to www.mysite.com/#ContactUs?. If the user then copies this URL and e-mails it to a friend the friend can not get back to that page because it's not in history and "#ContactUs?" means nothing to jqTouch on first entry.
I already know of one way to do this but I am looking for best practice. What's recommended?
hello there,. i ve problem, can you help me,.. i want to add animation in "go to" script,. i try this:
$('#laFactory').swipeLeft(function(e, info){
but still not add animation,.. i dont know what is wrong,. sorry for my english,..
thank regards.
@GnkMahen?
Hi, you do not need to use selector in the goTo parameter.
Simply do this instead > jQT.goTo('#id', 'slideleft');
To disable jqt back button navigation comment the following lines in goBack() function and return false from goBack() function.
//if (doNavigation(from.page, to.page, from.animation, true)) {