jQuery Mobile in $ (document). ready () how to use it?
Related links:
Note:
-
- Use $ (document). bind ('pageinit / pageshow'), not $ (document). ready ()
- default settings, jQueryMobile website after the first page of all pages are using AJAX to load, but only the first one document.ready executed when the page loads, that's why not document.ready.
- corresponding, pageinit / pageshow event is like an AJAX code to load the page callback (callback) function is triggered after the request was successful execution
jQuery Mobile li mobileinit event how to use it?
Related links:
mobileinit event action:
-
- change the default setting (To override default settings)
- bound before the page load event handler (bind pageshow / pageinit event handlers before page is loaded)
Note:
-
- mobileinit event handler code must be placed in jquery after loading, jquerymobile before loading
-
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
$(document).on("mobileinit", function(){
$(document).on('pageshow', 'div:jqmData(role="page"), div:jqmData(role="dialog")', function(event){
//pageshow handler goes here
});
$(document).on('pageinit', function() {
//pageinit handler goes here
});
});
</script>
<script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
jQuery Mobile in page sequence of events triggered what?
First all events can be found here: http :/ / api.jquerymobile.com / category / events /
-
-
pagebeforeload
,pageload
andpageloadfailed
are fired when an external page is loaded -
pagebeforechange
,pagechange
andpagechangefailed
are page change events. These events are fired when a user is navigating between pages in the applications. -
pagebeforeshow
,pagebeforehide
,pageshow
andpagehide
are page transition events. These events are fired before, during and after a transition and are named. -
pagebeforecreate
,pagecreate
andpageinit
are for page initialization. -
pageremove
can be fired and then handled when a page is removed from the DOM
-
Page loading jsFiddle example: http://jsfiddle. net / Gajotres / QGnft /
(Above copy from http://stackoverflow.com/questions/14468659/jquery-mobile-document-ready-vs-page-events , so good to explain why I do not!)
没有评论:
发表评论