Home  >  Article  >  Web Front-end  >  Analysis and solutions to the reasons why external JS is not loaded after the jQuery Mobile page jumps_jquery

Analysis and solutions to the reasons why external JS is not loaded after the jQuery Mobile page jumps_jquery

WBOY
WBOYOriginal
2016-05-16 17:40:11998browse

In web development using jQuery Mobile, when the page jumps (pageA => pageB), the JS referenced in pageB does not run successfully. Because, JQM does not load the entire page into the current dom, but only adds the data-role="page" element to the current dom.

Therefore, the external JS files introduced in

and the JS outside the tag cannot run normally, and they can be loaded successfully after refreshing the page.

Since this feature of JQM is unlikely to be actively changed, there are two ways to solve it :
First, register all external JS files that need to be used in the index page. Or use the master page to unify;
The second is to write the internal JS of the page under the data-role="page" tag, so that it can run no matter how the page jumps.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn