I could only ever bind pagebeforechange to the entire jquery mobile document, not an individual page. Can anyone explain why this doesn't work?
相关问题
- How to fix IE ClearType + jQuery opacity problem i
- jQuery add and remove delay
- Include empty value fields in jQuery .serialize()
- Disable Browser onUnload on certain links?
- how to get selected text from iframe with javascri
Selector for JQM pages:
Adding the event listener to all the pages in the document can be done as:
Fiddle using delegate:
Note using bind instead of delegate will NOT work for the aforementioned selector as ui-page class is added only on page creation.
In-order to use bind, use the following selector:
And add the event listener using(only after document is ready or body has loaded):
Fiddle using bind:
I also recommend using mobileinit event rather document ready!
I'm having the exact same problem, but I at least have a work-around for you. Warning: this is stupid, horrible code. But it does the job.
With jQuery Mobile - I'm pretty certain you don't bind to the document, but to the pageinit property.
Binding to the doc would create issues... keep in mind for this link to work on #home again you will need another event listener for beforepageshow or what you before the page is shown again.
This doc is very helpful...
(check the link for details) you can also use bind instead of live , Hope it helped.