如何在我的Emberjs Rails应用程序中包含jQuery Mobile

时间:2012-11-12 05:30:37

标签: ruby-on-rails jquery-mobile ember.js

今天我遇到了一个令人费解的问题,经过几个小时的搜索,我无法找到问题所在。我试图将jquery mobile包含到我的rails应用程序中。我已尝试手动引用库文件并使用jquery_mobile_rails gem。两种方法都可以将库插入我的应用程序,但是只要我添加jquery mobile,我的应用程序就不再加载了。刷新页面时,不会加载。控制台中有三个错误:

第一

Uncaught TypeError: Object <Ember.ArrayResourceController:ember141> has no method '_resourceRequest'
Jimux.appsMetaController.Em.ArrayResourceController.create.findAll
newFunc
(anonymous function)
(anonymous function)
(anonymous function) jquery.js:566
jQuery.extend.globalEval jquery.js:567
jQuery.ajaxSetup.converters.text script jquery.js:8107
ajaxConvert jquery.js:7992
done jquery.js:7628
callback jquery.js:8367
send jquery.js:8373
jQuery.extend.ajax jquery.js:7835
(anonymous function) jquery.js:5858
jQuery.extend.each jquery.js:613
jQuery.fn.extend.domManip jquery.js:5855
jQuery.fn.extend.append jquery.js:5628
jQuery.fn.extend.wrapAll jquery.js:5585
(anonymous function) jquery.js:5603
jQuery.extend.each jquery.js:613
jQuery.fn.jQuery.each jquery.js:243
jQuery.fn.extend.wrapInner jquery.js:5598
$.extend.initializePage jquery.mobile-1.2.0.js:9063
(anonymous function) jquery.mobile-1.2.0.js:9142
fire jquery.js:976
self.fireWith jquery.js:1084
jQuery.extend.ready jquery.js:408
DOMContentLoaded

第二

Uncaught TypeError: Cannot call method 'set' of undefined
Ember.Application.registerInjection.injection
(anonymous function)
(anonymous function)
visit
DAG.topsort
Ember.Application.Ember.Namespace.extend.runInjections
Ember.Application.Ember.Namespace.extend.initialize
(anonymous function)
fire
self.fireWith
jQuery.extend.ready

第三

GET http://localhost:3000/assets/images/ajax-loader.gif 404 (Not Found)

一旦我从//= require jquery.mobile-1.2.0移除application.js,我的应用就会再次按预期工作 - 没有任何上述错误。我只是想知道这里会发生什么。我想可能会有一些命名空间冲突,但我不确定是否是这种情况以及如何识别和修复它。

任何有关调试此问题的帮助将不胜感激。如果您在rails项目中使用Embeejs + jQueryMobile,我很想知道您如何将两个库包含到rails应用程序中,以及是否/如何处理任何冲突。

我使用的是Ember 1.0pre1,以及稍微修改过的ember-rest版本。

1 个答案:

答案 0 :(得分:3)

如果我没记错的话,jQuery Mobile会对DOM进行一些操作。这可能会对Ember产生问题,因为Ember希望没有其他库操纵DOM元素来跟踪视图或绑定。