這令人沮喪!我不能讓我的點擊事件處理程序工作。我花了幾個小時試圖找出問題是什麼,但失敗了。爲什麼我的點擊事件處理程序不工作?
下面是我的模板代碼:
<template name="ViewStats">
<div class="tileMenu" > </div>
</template>
的tileMenu具有嵌入式圖像,足夠大到可以點擊。 我甚至試圖用更大的圖像替換嵌入圖像,希望增加可點擊面積,但似乎沒有任何區別。
以下是我的CSS:
.tileMenu{
position: absolute;
left: 115px;
z-index: 2;
height: 49px;
background: url(images/tileMenu.png) no-repeat;
top: 1px;
display: block;
height: 24px;
margin-left: 1PX;
margin-top: 2px;
float: left;
width: 17px;
background-repeat: no-repeat;
background-position: right 4px top 3px;
background-size: 75% 75%;
}
而現在它不能火起來的事件handlar。 我在做什麼錯?
Template.ViewStats.events({
'click .tileMenu': function (event) {
alert("You clicked tileMenu");
}
});
有人可以解釋爲什麼我的警報功能無法啓動?
在此先感謝!
您要放置模板的位置? – winter
@amaia在main.html中。與main.js中的事件相同的文件夾 – SirBT