jquery - JQM back button loses data of previous page -


i have issue jquery mobile , button feature.

i have page run ajax request on remote server when displayed. ajax launched through pagebeforeshow event. event attached div [data-role="page"] attribute i'm using multiple html file:

 <div data-role="page" data-theme="b" id="favorites">    <div data-role="content" data-theme="b">     <div id="ajax">             display ajax result containing link other html page         </div>     </div>  </div> 

here javascript:

$('#favorites').on('pagebeforeshow', function(event) {    launchajax();    });      

this working fine when page displayed first time. ajax results contain link page user can follows. when user follow link display button (generated jquery mobile) in order him came @ intiale page containing ajax result.

however when clicking button, initiale page displayed blank. have last resulted generated ajax dislayed or @ least way relaunch ajax function display initiale results.

i have tried play with jqm cache:

 $.mobile.page.prototype.options.domcache = true; 

but doesn't solved issue , dom elements not cached correctly (maybe due fact i'm using seperate html files)

i have test app on chrome desktop , on android using phonegap, issue present both.

does have right way this?

thanks lot

best regards.

you using incorrect way of page event binding. way bind page event through delegated binding.

so instead of code:

$('#favorites').on('pagebeforeshow', function(event) {     launchajax();    }); 

use this:

$(documents).on('pagebeforeshow', '#favorites',function(event) {     launchajax();    });     

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -