Using jQuery Mobile version 1.2.0
I am dynamically generating HTML using JavaScript ($(selector).html(content)
), adding it to the DOM, and then displaying it ($.mobile.changePage()
).
After that, I make an AJAX call, retrieve some data, and re-generate the HTML (keeping the parent element, $(selector)
, the same but changing its content with html(...)
).
At this point, the HTML does not have jQM styling applied.
According to the documentation, I should simply invoke the page()
function on the parent element, like $(selector).page()
.
However, other parts of the documentation suggest triggering the create
event instead, for example: $(selector).trigger("create")
.
The issue is that neither of these methods seems to work - the jQM styling is still not being applied.
After examining the jQM source code, I attempted triggering the pagecreate
event on the element which actually worked. However, this method is not officially documented, leaving me unsure about its future compatibility with jQM releases.
Additionally, I came across a mention in the documentation stating that calling page()
on a page should only be done once..
In any case, is there a clear or standard way to instruct jQM to "enhance" the entire element along with its child elements? Or would it be advisable to continue using the pagecreate
event trigger?
Thank you!