简体   繁体   English

流星和Hammer JS软件包的Tracker afterFlush错误

[英]Tracker afterFlush error with Meteor and Hammer JS package

I'm trying to use the hammer:hammer 2.0.4_2 package with Meteor 1.0.1 and I'm getting the following error: 我正在尝试将Hammer:hammer 2.0.4_2包与Meteor 1.0.1结合使用,但出现以下错误:

Exception from Tracker afterFlush function: undefined is not a function TypeError: undefined is not a function 来自Tracker afterFlush函数的异常:未定义不是函数TypeError:未定义不是函数

I figured that the error has something to do with DOM not being rendered yet, because of the Helper Block. 我发现由于Helper Block,该错误与尚未呈现DOM有关。 So far I couldn't find an answer to this anywhere. 到目前为止,我在任何地方都找不到答案。 Does someone else have the same error or knows how this can be fixed? 其他人是否有相同的错误或知道如何解决?


client/profile.js 客户机/ profile.js

Template.myTemplate.rendered = function() {

    this.$('body').hammer({          <-- Line of the Error in Console..
         drag_min_distance:1,
         swipe_velocity:0.1
    })
 }

Template.myTemplate.events({
    'press #mcPress': function() {
        console.log('yay!')
    }
})

client/profile.html 客户机/ profile.html

{{#with thisUser}}

    // some html stuff

    <div id="mcPress">Some content</div>

{{/with}}

Hammer.js as a stand-alone (which is how the official package is provided) does not ship with the jQuery plugin , so you can't use that syntax without manually adding the jQuery plugin yourself. Hammer.js作为独立版本(提供官方软件包的方式) jQuery插件一起提供 ,因此,您必须自己手动添加jQuery插件才能使用该语法。

It's pretty easy to do your own local fork of that package and bolt the plugin on (I haven't released this yet as I'm quite sensitive about the Atmosphere namespace mess problem). 您可以很容易地在该程序包中创建自己的本地派生插件,然后将插件固定在上面(我尚未发布此插件,因为我对Atmosphere命名空间混乱问题非常敏感)。 Alternatively, you could just include the plugin on page load. 或者,您可以只在页面加载中包含该插件。 Either way, that syntax should work or, failing that, you just have to use the non-jQuery syntax described in the core docs . 无论哪种方式,该语法都应该起作用,否则,您只需要使用核心docs中描述的非jQuery语法即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM