javascript - jquery Pageinit called multiple times -
i new jquery development. creating single page application. calling pageinit method when navigate 1 page page. when navigate , between 2 screens see page init called multiple times.
$(document).on("pageinit", '#docpage', function(event) { home.doc.init(); });
and while navigating calling unbind event also.
$('#backbutton').on('tap', function(event) { event.preventdefault(); $.mobile.changepage("homepage.html", { transition: "fade", reverse: false, changehash: false }); teardown(); }); }; teardown(){ home.doc.unbindevents(); }
can 1 guide me best practice of navigating in single page application. in advance.
this due pageinit
listener being assigned more once - check not being re-added each time 'navigate' different page.
your unbinding not working expected. try , change anonymous function $(document).on("pageinit", '#docpage', function(event) { home.doc.init(); })
to named function declared in code. provide insight.
Comments
Post a Comment