今天我遇到了一个令人费解的问题,经过几个小时的搜索后,我无法找到问题所在。我正在尝试将jquery移动到我的rails应用程序中。我已经尝试手动引用库文件,并使用jquery_mobile_rails宝石。这两种方法尽可能将库插入我的应用程序,但只要我添加jquery移动,我的应用程序不再加载。刷新页面时,它不会加载。有三个错误控制台:如何在我的Emberjs Rails应用程序中包含jQuery Mobile
1:
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
3:
GET http://localhost:3000/assets/images/ajax-loader.gif 404 (Not Found)
一当我从application.js
中删除//= require jquery.mobile-1.2.0
后,我的应用程序再次按预期工作 - 没有出现上述任何错误。我只是想知道这里会发生什么。我猜可能会有一些命名空间冲突,但我不确定是否是这种情况,以及如何识别和修复它。
任何帮助调试此问题将不胜感激。如果您在rails项目中使用Embeejs + jQueryMobile,我很想知道您是如何将两个库包含到您的rails应用程序中的,以及您是否正在处理任何冲突。
我使用Ember 1.0pre1和一个稍微修改后的版本的余烬。
哦不!你在说我认为你在说什么吗?你认为有什么办法解决这个问题吗?这有点奇怪,因为我还没有开始使用jqm,并且我得到了这些错误。感谢快速响应btw,卢克! – Aras
@Aras - 我不确定。有迹象表明,这是可能的。例如http://stackoverflow.com/questions/9857247/can-i-use-jquery-mobile-with-emberjs –
是的,这个帖子让我相信这是可能的。虽然已经过去了几个月,但事情发生了很大变化。我基本上甚至没有加载我的应用程序,因为我引用了jquery mobile,所以我还没有尝试创建任何jqm元素。你有更多的经验,你有什么提示,我怎么能调试这个问题多了解一些,或消除一些假设?我很困惑! – Aras