jquery - Reload previously unloaded content ajax -
not sure how begin thinking solving issue. many searches loading , unloading ajax return results how unload before loading new stuff, not reload unloaded content.
i have web app loads content target div, contains links unload first loaded content , load in new content same target div. create script change href
reload content unloaded.
to put perspective, building portfolio loads portfolio full of project thumbs index. clicking on project thumb unload thumbs , load project details. button link load portfolio thumbs , there, clicking again link main index.
the structure this:
- /index.php
- /portfolio/index.php (list of thumbnails linking each project)
- /portfolio/project.php (gathers relevant information project)
i need button that: isn't shown when @ state 1 links index @ state 2 , links portfolio @ state 3.
for moment, have partially works, relies on me typing in specific pages check. i'd dynamically changes.
//if link containes project.php, show button, if not hide it. if(destination.indexof('project.php')>=0){ $('div.back-button').css({'display':'block'}); $('a.back-button').attr('href', 'portfolio'); } else if(destination.indexof('portfolio')>=0){ $('div.back-button').css({'display':'block'}); $('a.back-button').attr('href', '/app'); } else{ $('div.back-button').css({'display':'none'}); };
i'm guessing need create variable somewhere catches content being loaded , becomes location return to. how start chain off when nothing clicked , delay use of until 1 more click later?
for example, when click portfolio index, want remember 'portfolio' loaded, use variable button location once have clicked on project. once project loaded, button locate portfolio.
any on how tackle appreciated!
you can see how far i've got @ http://joeallam.co.uk/app
after you've loaded want keep via ajax, save innerhtml of element javascript variable. when presses back, put contents of variable same div loads ajax content.
var savethis; savethis = $('#ajaxtarget').html() //save $('#ajaxtarget').html(savethis) // load
Comments
Post a Comment