Advertisement
KzDrew

sandbox_slider.js

Aug 7th, 2013
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     // -- mobileinit event --
  2.     // -- this code is executed once, when jquery mobile is loaded (and must be placed before jqm is loaded)
  3.     // -- this is where you can change default options or behavior
  4.     $(document).bind('mobileinit', function() {
  5.         console.log('mobileinit event');
  6.         //$.mobile.page.prototype.options.domCache = true;
  7.     });
  8.  
  9.  
  10.     $(function() {
  11.  
  12.  
  13.             console.log('jquery document ready function');
  14.  
  15.             // -- pagebeforechange event --
  16.             // -- this code is executed every time ANY page (cached or new) is about to be loaded, BEFORE the page is displayed/loaded
  17.             // -- this is where you can see what page was requested,  stop the request, or alter the request
  18.             $(document).on( "pagebeforechange", function( event, data ){
  19.                 if ( typeof data.toPage === "string" ) {
  20.                     console.log('pagebeforechange event - ALL pages');
  21.  
  22.                     console.log(data);
  23.  
  24.                     // .. do stuff here
  25.                 }
  26.             });
  27.  
  28.             // -- pageinit event that fires for SPECIFIC PAGE ONLY --
  29.             // -- this code is executed only once upon initital page load (or if it is no longer in the cache)
  30.             $(document).on("pageinit", "#example_page_one", function() {
  31.                 console.log('pageinit event - #example_page_one only');
  32.                 // .. do stuff for example page one here
  33.  
  34.  
  35.             });
  36.  
  37.  
  38.             // -- pageshow event --
  39.             // -- this code is executed every time ANY page is shown (cached or new)
  40.             // -- this is where you can manipulate the contents of the page being shown - think of it as JQM's version of jquery's $(function(){ .. }
  41.             $(document).on( "pageshow", function(){
  42.                 console.log('pageshow event - ALL pages');
  43.                 // .. do stuff here
  44.             });
  45.  
  46.             // -- pageshow event that fires for SPECIFIC PAGE ONLY --
  47.             // -- the second parameter targets the id value of the page div used in the body section, aka: <div data-role="page" id="example_page_one" ..> .. </div>
  48.             // -- this code is executed every time the 'example_page_one' page is loaded (cached or new)
  49.             // -- we include code for all the different pages at once in the head because jqm will only every process the head .. /head content ONCE and never again
  50.             $(document).on("pageshow", "#example_page_one", function() {
  51.                 console.log('pageshow event - #example_page_one only');
  52.                 // .. do stuff for example page one here
  53.             });
  54.  
  55.             $(document).on("pageshow", "#example_page_two", function() {
  56.                 console.log('pageshow event - #example_page_two only');
  57.                 // .. do stuff for example page two here
  58.             });
  59.  
  60.             $(document).on("pageshow", "#example_page_three", function() {
  61.                 console.log('pageshow event - #example_page_three only');
  62.                 // .. do stuff for example page three here
  63.             });
  64.  
  65.  
  66.     });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement