jQuery-Mobile Meteor sample integration and/or integration guidelines

a 夏天 提交于 2019-11-30 10:51:12

问题


I'm impressed by Meteor and would like to use it with jQuery-Mobile. I'd like to know if somebody has already built a sample integration app. If not, some guidelines would be great.

Regards,

Cédric


回答1:


I was wondering about this as well so I made a sample app:

http://jqmdemo.meteor.com/

And it seems to work well. You can find the source code here:

https://github.com/snez/jqm-meteor

There are a few gotchas when using the two together, see the comments in the code.

UPDATE: It looks like meteor.com is rolling upgrades to the meteor framework breaking old code there. Use this project as a reference only as there are better ways to do the same thing with the newer framework versions.




回答2:


I wasn't able to get jQuery Mobile to work initially when I tried to bundle the framework files in the clients directory. Meteor was throwing an error on JS files that were attempting to set the DOCTYPE, even files in the examples folder which were never referenced. By using the CDN-hosted version and disabling autoInitializePage as mentioned in a comment above, I got it to work without accessing any undocumented APIs.

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" />
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script>
<script type="text/javascript">
     $( document ).bind( "mobileinit", function( event, data ){
          $.mobile.autoInitializePage = false;
     });    
</script>



回答3:


I suggest taking a look at the jQuery package in the /packages/jquery folder.

All this does is add in the jquery.js file into the stack of files to get sent to the client. If you are after this you could add your own package called jquery-mobile and include the files it needs.

See the package.js file for how it works:

https://github.com/meteor/meteor/blob/master/packages/jquery/package.js

So just add the mobile files into your jquery-mobile package and do something like:

Package.on_use(function (api) {
  api.add_files('jquery.mobile-1.1.0.min.css', 'client');
  api.add_files('jquery.mobile-1.1.0.min.js', 'client');
});


来源:https://stackoverflow.com/questions/10139425/jquery-mobile-meteor-sample-integration-and-or-integration-guidelines

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!