javascript - Trigger function on page change jQuery Mobile -


i'm trying run function each time user changes 'page'in jquery mobile.

$(document).ready(function(){} 

doesn't work because pages contained in same .html. way can work if listen on nav buttons this

$('#navnext').click(function() { retrievesession(); }); 

this causes whole lot of head aches tried this

function retrievesession(){       var activepage = $.mobile.pagecontainer.pagecontainer("getactivepage");     var activepageid = activepage[0].id;       $( "#" + activepageid ).on( "pagechange", function() {         if (activepageid === "q1"){                                                 alert("q1");              } else if (activepageid === "q2"){                               alert("q2");              } else if (activepageid === "q3"){                               alert("q3");                  } else if (activepageid === "q4"){                               alert("q4");             };      }); } 

then run function in $(document).ready(function(){}, app still runs fine, no alert when navigating through 'pages'. no exceptions either. have searched on here , can find vague connections through other questions don't me solution.

what doing wrong here?


Comments