【发布时间】:2016-10-08 22:30:29
【问题描述】:
我正在浏览“Meteor in Action”book(myfridge 应用程序)的第一个示例。 在我们为产品添加拖放功能的最后一步中,我的应用似乎无法识别 jquery。我选择了最新版本,因为这本书有点过时了。
我已经在/client/main.html 文件中包含了 jquery CDN 的要求
<head>
<title>myfridge</title>
<script src="//code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="//code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
</head>
在我的/client/main.js 中,我包含了使fridge 和productList 可拖放和productListItem 可拖动的必要声明。
Template.fridge.onRendered( function () {
var templateInstance = this;
templateInstance.$('#fridge').droppable({
drop: function(evt, ui) {
var query = { _id: ui.draggable.data('id') };
var changes = { $set: { place: 'fridge' } };
Products.update(query, changes);
}
});
});
Template.productList.onRendered( function() {
var templateInstance = this;
templateInstance.$('#supermarket').droppable({
drop: function(evt, ui) {
var query = { _id: ui.draggable.data('id') };
var changes = { $set: { place: 'supermarket'} };
Products.update(query, changes);
}
});
});
Template.productListItem.onRendered( function() {
var templateInstance = this;
templateInstance.$('.draggable').draggable({
cursor: 'move',
helper: 'clone'
});
});
我查看了其他有类似问题的帖子,但这些提示似乎对我不起作用。
编辑:控制台中的错误消息是
Exception from Tracker afterFlush function:
debug.js:41 TypeError: templateInstance.$(...).droppable is not a function
at .<anonymous> (main.js:9)
at template.js:119
at Function.Template._withTemplateInstanceFunc (template.js:465)
at fireCallbacks (template.js:115)
at .<anonymous> (template.js:208)
at view.js:107
at Object.Blaze._withCurrentView (view.js:538)
at view.js:106
at Object.Tracker._runFlush (tracker.js:511)
at onGlobalMessage (setimmediate.js:102)
debug.js:41 Exception from Tracker afterFlush function:
debug.js:41 TypeError: templateInstance.$(...).droppable is not a function
at .<anonymous> (main.js:22)
at template.js:119
at Function.Template._withTemplateInstanceFunc (template.js:465)
at fireCallbacks (template.js:115)
at .<anonymous> (template.js:208)
at view.js:107
at Object.Blaze._withCurrentView (view.js:538)
at view.js:106
at Object.Tracker._runFlush (tracker.js:511)
at onGlobalMessage (setimmediate.js:102)
debug.js:41 Exception from Tracker afterFlush function:
debug.js:41 TypeError: templateInstance.$(...).draggable is not a function
at .<anonymous> (main.js:34)
at template.js:119
at Function.Template._withTemplateInstanceFunc (template.js:465)
at fireCallbacks (template.js:115)
at .<anonymous> (template.js:208)
at view.js:107
at Object.Blaze._withCurrentView (view.js:538)
at view.js:106
at Object.Tracker._runFlush (tracker.js:511)
at onGlobalMessage (setimmediate.js:102)
debug.js:41 Exception from Tracker afterFlush function:
debug.js:41 TypeError: templateInstance.$(...).draggable is not a function
at .<anonymous> (main.js:34)
at template.js:119
at Function.Template._withTemplateInstanceFunc (template.js:465)
at fireCallbacks (template.js:115)
at .<anonymous> (template.js:208)
at view.js:107
at Object.Blaze._withCurrentView (view.js:538)
at view.js:106
at Object.Tracker._runFlush (tracker.js:511)
at onGlobalMessage (setimmediate.js:102)
【问题讨论】:
-
嗨,你的错误信息是什么?
标签: javascript jquery meteor