模板。$(选择器)不工作流星

时间:2015-06-26 13:41:49

标签: meteor

我发现将DOM搜索限制为当前模板而不是document是一种很好的模式,因此我开始将所有document.querySelector()替换为template.find()和jquery {{ 1}} $(selector)。 内部活动一切都很好,但是在这段代码(template.$(selector))中,它只是不起作用,我在控制台中得到:onRendered

TypeError: undefined is not an object (evaluating 'template.$')

有谁知道发生了什么?

1 个答案:

答案 0 :(得分:2)

内部生命周期事件回调,例如public Bitmap getDetectedImage() { int rx, rx, lx, ly, ...; double dRightLeft = 0; ... //righteyeloop for (int x = fo.rightEye.X; x < (fo.rightEye.X + fo.rightEye.Width); x++) { for (int y = fo.rightEye.Y; y < (fo.rightEye.Y + fo.rightEye.Height); y++) { //segmentation...// rPixel++; result.byteImage[x, y].R = 0; result.byteImage[x, y].G = 255; result.byteImage[x, y].B = 0; //to get the the first pixel detected// if (rPixel == 1) { result.byteImage[x, y].R = 255; result.byteImage[x, y].G = 0; result.byteImage[x, y].B = 0; rx = x + (fo.rightEye.Width / setting.featureWidth * setting.eyeHeight / setting.eyeWidth); ry = y + (fo.rightEye.Height / setting.featureWidth * setting.eyeHeight / setting.eyeWidth); } } } //lefteyeloop basically the same type as righteyeloop// ..... //this to count the distance of righteye and lefteye double rl = ((rx - lx) * (rx - lx) + (ry - ly) * (ry - ly)); double dRightLeft = Math.Pow(rl, 0.5); } onCreatedonRendered,当前模板实例绑定到onDestroyed关键字。

简单地用this替换template(在此上下文中未定义){/ 1}:

this