External page disappears on refresh - jQuery mobile

I am developing a jquery mobile application that loads external pages into a div by clicking a link,

external pages that I call in the div also have links to other pages.

when I click on these links to other pages and I use the back link ("javascript:history.back()") to go

on the previous page on which the external page was, the external page disappears if I do not click on the link that calls the external page to load

page again. I thought that maybe this is a script that can cache the loaded page, so when I use

the back link ("javascript:history.back()") to return again, I will find the page there.

here is the script that I use to load the external page:

 $(document).ready(function() { $('.newsclick').on('click', function(event) { $('#headline_container').load('news/headlines.asp'); }); }); 

HTML

 <div data-role="page" id="news"> <div data-role="header"> <h1>News</h1> </div> <div id="headline_container" data-role="content">Content</div> <div data-role="footer"> <h4>Footer</h4> </div> </div> 
+6
source share
1 answer

External pages are removed from the DOM upon transition to another page. If you want to save external cached pages, add data-dom-cache="true" to the page div.

 <div data-role="page" id="news" data-dom-cache="true"> 
+8
source

Source: https://habr.com/ru/post/981724/


All Articles