堕落问题,我需要动态设置一个画廊。所以我想找到类.gallery并附加一些HTML代码。我的解决方案是:$(".gallery").append('<div class="row">');
现在奇怪的是,有时候,jquery会找到这个选择器,有时候不会。我已经包含了$( document ).ready(function() {
,但这并未改变任何内容。不知道怎么解决这个问题?
我得到的错误:`
TypeError: $(...).html(...) is undefined
Stack-Trace:
setImages/</<@http://localhost:3000/app/app.js?hash=1ff5b02af1c2e6f71af9355d997116d10d0ba91f:342:36
require<.node_modules.meteor.jquery["jquery.js"]/</jQuery.Callbacks/fire@http://localhost:3000/packages/jquery.js?hash=22a0055f59bd150c435c5aba34c7c59076b8bcd9:3201:10
require<.node_modules.meteor.jquery["jquery.js"]/</jQuery.Callbacks/self.add@http://localhost:3000/packages/jquery.js?hash=22a0055f59bd150c435c5aba34c7c59076b8bcd9:3247:7
require<.node_modules.meteor.jquery["jquery.js"]/</jQuery.fn.ready@http://localhost:3000/packages/jquery.js?hash=22a0055f59bd150c435c5aba34c7c59076b8bcd9:3481:2
setImages/<@http://localhost:3000/app/app.js?hash=1ff5b02af1c2e6f71af9355d997116d10d0ba91f:330:21
Tracker.Computation.prototype._compute@http://localhost:3000/packages/tracker.js?hash=6f5d0f5486aaa54b0abe636174eeb06dcc2a736b:351:5
Tracker.Computation@http://localhost:3000/packages/tracker.js?hash=6f5d0f5486aaa54b0abe636174eeb06dcc2a736b:239:5
Tracker.autorun@http://localhost:3000/packages/tracker.js?hash=6f5d0f5486aaa54b0abe636174eeb06dcc2a736b:590:11
setImages@http://localhost:3000/app/app.js?hash=1ff5b02af1c2e6f71af9355d997116d10d0ba91f:328:13
bindDataContext/<@http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:2994:14
Blaze._wrapCatchingExceptions/<@http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:1653:14
wrapHelper/</<@http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:3046:14
Template._withTemplateInstanceFunc@http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:3687:12
wrapHelper/<@http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:3045:12
Spacebars.call@http://localhost:3000/packages/spacebars.js?hash=65db8b6a8e3fca189b416de702967b1cb83d57d5:172:12
Spacebars.mustacheImpl@http://localhost:3000/packages/spacebars.js?hash=65db8b6a8e3fca189b416de702967b1cb83d57d5:106:10
Spacebars.mustache@http://localhost:3000/packages/spacebars.js?hash=65db8b6a8e3fca189b416de702967b1cb83d57d5:110:16
require<.client.Website.Vorlagen["template.vorlageBlogArtikel.js"]/Template.vorlageBlogArtikel</</<@http://localhost:3000/app/app.js?hash=1ff5b02af1c2e6f71af9355d997116d10d0ba91f:137:14
doRender@http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:2027:20
viewAutorun/</<@http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:1875:18
Template._withTemplateInstanceFunc@http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:3687:12
viewAutorun/<@http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:1873:14
Blaze._withCurrentView@http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:2214:12
viewAutorun@http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:1872:12
Tracker.Computation.prototype._compute@http://localhost:3000/packages/tracker.js?hash=6f5d0f5486aaa54b0abe636174eeb06dcc2a736b:351:5
Tracker.Computation@http://localhost:3000/packages/tracker.js?hash=6f5d0f5486aaa54b0abe636174eeb06dcc2a736b:239:5
Tracker.autorun@http://localhost:3000/packages/tracker.js?hash=6f5d0f5486aaa54b0abe636174eeb06dcc2a736b:590:11
Blaze.View.prototype.autorun@http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:1885:14
Blaze._materializeView/<@http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:2021:5
Tracker.nonreactive@http://localhost:3000/packages/tracker.js?hash=6f5d0f5486aaa54b0abe636174eeb06dcc2a736b:617:12
Blaze._materializeView@http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:2020:3
materializeDOMInner@http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:1476:9
Blaze._materializeDOM@http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:1418:3
Blaze._materializeDOM@http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:1427:7
doMaterialize@http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:2033:32
Tracker.nonreactive@http://localhost:3000/packages/tracker.js?hash=6f5d0f5486aaa54b0abe636174eeb06dcc2a736b:617:12
doRender@http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:2031:9
viewAutorun/</<@http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:1875:18
Template._withTemplateInstanceFunc@http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:3687:12
viewAutorun/<@http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:1873:14
Blaze._withCurrentView@http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:2214:12
viewAutorun@http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:1872:12
Tracker.Computation.prototype._compute@http://localhost:3000/packages/tracker.js?hash=6f5d0f5486aaa54b0abe636174eeb06dcc2a736b:351:5
Tracker.Computation.prototype._recompute@http://localhost:3000/packages/tracker.js?hash=6f5d0f5486aaa54b0abe636174eeb06dcc2a736b:370:9
Tracker._runFlush@http://localhost:3000/packages/tracker.js?hash=6f5d0f5486aaa54b0abe636174eeb06dcc2a736b:509:9
onGlobalMessage@http://localhost:3000/packages/meteor.js?hash=ae8b8affa9680bf9720bd8f7fa112f13a62f71c3:401:11
EventListener.handleEvent*usePostMessage@http://localhost:3000/packages/meteor.js?hash=ae8b8affa9680bf9720bd8f7fa112f13a62f71c3:410:5
@http://localhost:3000/packages/meteor.js?hash=ae8b8affa9680bf9720bd8f7fa112f13a62f71c3:439:3
@http://localhost:3000/packages/meteor.js?hash=ae8b8affa9680bf9720bd8f7fa112f13a62f71c3:292:2
@http://localhost:3000/packages/meteor.js?hash=ae8b8affa9680bf9720bd8f7fa112f13a62f71c3:11:2
我正在执行的部分代码:
Tracker.autorun(function() {
if (Session.get("bereit")){
$( document ).ready(function() {
var knoten = document.getElementsByClassName("gallery");
console.log(knoten);
$(".gallery").append('<div class="row">');
console.log("i was here")
var item = $('.gallery');
console.log(item.length);
})
}
})
是的,所有会话和订阅都已准备就绪,所以对我来说这似乎是一个“jquery问题”