Response title
This is preview!
1) jQuery Mobile loads subsequent pages via Ajax. But what should those subsequent pages look like? Full web pages with a head, etc? Or just the <body> contents?
pagecreate event.
3) Is there any way to access the jQM-returned HTML before jQM turns it into virtual pages?
http://jquerymobile.com/demos/1.2.0/docs/pages/page-links.html(I haven't found any really detailed documentation on how Ajax loading happens. If there is a write-up on what's happening *in detail*, I'd love a pointer.)
Not sure what you mean by "the entire HTML structure returned from the server". Normally, that is the head and body of a single page - unless you are using a multi-page document. Although there is a provision for multi-page documents, I don't recommend it, and it is one of the top reasons why people come here with problems. Don't do it.As I understand it, the 'pagecreate' event is called once for each virtual page (data-role='page') and not for the entire HTML structure returned from the server.
What I would like access to is the HTML returned, especially the 'body' tag, so that I can copy some data attributes that are stored there to the individual page DIVs.
Some data is available only after the page has rendered, so it is added to the <body> tag as created by the decorator.
The individual documents can contain multiple data-role pages
I know that the way we're using multi-page documents is entirely appropriate.
Don't know what you mean by "stripped down to individual pages".is there any way to access the HTML fetched by the ajax loader, before it is stripped down to individual pages?
The functionality provided by this widget is a workaround for the jQuery Mobile loadPage() function which only loads the first page in an AJAX response. You do not use this widget on your initial document load
It certainly would be marginally (but only marginally) more efficient if the server were to return only the page content, rather than a complete document with <head>. But jQuery Mobile doesn't work that way, and there isn't an option to make it work that way.it seems like it would be more efficient to detect a jQM ajax loader request and return only the page divs, rather than the entire wrapper document.
Not sure what you are asking. This is for letting the server know that it's serving an Ajax page? For what purpose?Does jQM support the ability to add a parameter when it's performing an ajax load?
I think you will be sadly disappointed if you go down that route.I have gone down that route, and the site seems to be working fine. That's not the issue. (As an example page, see Working at Microsoft . All of the links in the 'Why Work for Us' section are to sub-pages.
Not sure what you are asking. This is for letting the server know that it's serving an Ajax page? For what purpose?
Yes, to allow the server to return only the <div data-role='page'> elements.
It appears that you don't have an answer to my initial question. I appreciate your suggestions that it was a mistake to use jQM, but I disagree.
Only one problem with your example: that site doesn't use jQuery Mobile. It uses jQuery UI.(As an example page, see Working at Microsoft . All of the links in the 'Why Work for Us' section are to sub-pages.
I believe that you're wrong when you say "The AJAX loader never loads multiple pages from a single document."
Documents loaded via Ajax will select the first page in the DOM of that document to be loaded as a jQuery Mobile page element. As a result the developer must make sure to manage theid
attributes of the loaded page and child elements to prevent confusion when manipulating the DOM
If you link to a multipage document, you must use adata-ajax="false"
attribute on the link to cause a full page refresh due to the limitation above where we only load the first page node in an Ajax request due to potential hash collisions. There is currently a subpage plugin that makes it possible to load in multipage documents.
Only one problem with your example: that site doesn't use jQuery Mobile. It uses jQuery UI.
I answered that.My initial question remains unanswered. Is there any way to access the ajax-loaded HTML before it's disassembled and injected into the existing DOM?
is there any way to access the HTML fetched by the ajax loader, before it is stripped down to individual pages?
Don't know what you mean by "stripped down to individual pages".
The loader takes the document content, minus <head> and loads it into the DOM. It then "enhances" the content of the page by instantiating the widgets found in the page. You have can a callback called either before or after the page is enhanced, and before the page is displayed. You can do any DOM manipulation you might like in these callbacks.
If you are asking if it's possible to modify the page before it is inserted into the DOM, the answer is "no".
© 2013 jQuery Foundation
Sponsored by and others.