0

如何以及在何处将您自己的 JS 文件放入 JQueryMobile Web 应用程序?

我发现的一些建议:

  • 仅在网络应用的第一页,通常是 index.html
  • 在 JQM 页面内

哪个是更好的方法?

4

3 回答 3

1

After your jQuery Library and BEFORE your jQuery mobile library. I place all my script tags at the end of the body...but that's not a must...

<script type="text/javascript" src="jQuerySource.js">
<script type="text/javascript">
/*Your stuff*/
</script>
<script type="text/javascript"  src="jQueryMobileSource.js">

Why?: Because when you're building your jQM application you're going to want your event bindings to be defined before jQuery mobile gets initialized and fires the 'mobileinit' event and your first page's 'pageinit' event.

于 2012-12-04T01:28:07.567 回答
0

Just put your script after the JQM script tag

Yeah, that's all

于 2012-12-04T01:27:46.273 回答
0

It is a good idea to use jQueryMobile javascripts from Google CDNs because of following reasons: 1. You can directly include minified version in your pages. 2. You save bandwidth cost 3. Most importantly there are good chances that the JS might already be loaded on your user browser's. Because many other web apps use them. So you should use

<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js">

So, if all your code is inside document.ready() ; you can use it at end [ which loads the page faster]

于 2012-12-04T01:30:27.093 回答