last day (16 days later) » 

9:42 AM
0
A: JQuery mobile want to wipe data when back button pressed

OmarSince you're using Single Page Model only landing page "form.html" is cached and other external pages are removed from DOM once you navigate off them. In that case, you don't have to worry to refresh results.html because it will be loaded again. To reset form elements in form.html, wrap element ...

 
So, I did type page id #pageResult into this $(document).on('pagebeforeshow', "#pageResult", function () { ...}) . That doesn't select just that one .ui-content in #pageHome of the form.html?
 
@huggie note that as of 1.4 all page events have changed into pagecontainer events either way, you always have to be specific. $(".ui-content") refers to first content div in DOM while $(".ui-content", this) or $(this).find(".ui-content"), etc. will target that selector in that specific page.
@huggie btw, toPage was added to all pagecontainer events in jQM 1.4.2. Hence I recommend using jQM 1.4.5 to be in the safe side.
 
Alright, at least changing into your code works wonderfully. Thanks. BTW, as to my first question in the original post. Do you have an explanation for that? (not required for bounty). Also can you clarify what a single page model is? Apparently it doesn't mean "one html file". So for JQuery mobile that isn't the only model?
 
@huggie you mean first point? All libraries/style sheets/js code should be placed in head of all html files. SPM: each page in a separate html file. MPM: all page divs in one html file. You're welcome :) don't hestiate to ask for further details upon this topic.
 
I got SPM and MPM reversed then. Thanks for pointing it out. After some trial and error, I noticed that just by modifying $('.ui-content') to $('.ui-content', data.toPage) solved the problem. As for my first question, when I originally put the code $(document).on('pagebeforeshow', "#pageResult", function () {...} in the head of result.html it doesn't work at all. Why is that?
First time using chat.
 
9:44 AM
@huggie because JQM uses ajax to load pages. It loads all tags of landing page. For external pages, it loads ONLY first page div it finds in that file. Anythinf outside that div is neglected. That's why you should place all code, styles, etc in head section of all pages. Because in case user force refresh, it will reload code, styles, libraries.
Welcome ;)
ive used it million times haha
 
I don't understand what you just said because it seems contradicting to me. What I'm saying is that codes from external pages (like my result.html) doesn't get loaded. But at the same time you are saying I should place all code in the head section of all pages. By pages you mean HTML files?
The code where I inserted DOM elements to show input results in result.html, that code, when written in result.html doesn't work. =/
 
10:06 AM
@huggie I was afk
ill elaborate, it looks like I have confused you.
form.html is the first page a user opens right?
jqm loads all page content, all html tags in DOM and caches that page. It's called landing page.
Now, navigating to result.html (external page). JQM loads only "page div" data-role=page. All other html tags are trashed.
so head tag of result.html isn't loaded, code in head isn't loaded. Therefore, the code to you want to run for result.html should be placed in head of form.html
Why did I tell you to place all libraries/style sheets, etc in head of each and every page? Because if a user refreshes (f5) result.html, the framework will reload and result.html will becomes landing page. If the head is empty, the framework won't initialize.
ill create a demo to facilitate understanding JQM and Ajax navigation.
@huggie
Meanwhile, read about pagecontainer events jqmtricks.wordpress.com/2014/03/26/jquery-mobile-page-events I need to update it to reflect changes in 1.4.5
 
10:50 AM
Whenever you get back @Omar me
 
 
2 hours later…
12:28 PM
@Omar Thanks Omar, everything is crystal clear now. I appreciate it. Thank you so much!
 
1:04 PM
@huggie you're welcome :)
 

  last day (16 days later) »