2013-03-13 113 views
0

這裏是我的按鈕單擊處理程序:流星事件處理抑制問題

Template.kanjifinder.events({ 
    'click input.btnOK': function() { 
    console.log("click"); 
     SetCharacters(); 
     } 
}); 

但是在我下面添加事件處理程序爲我的文字輸入上面的按鈕,點擊代碼已停止工作。

Template.kanjifinder.events = ({ 
'keydown input.txtQuery': function (evt) { 
    if (evt.which === 13) { 
    SetCharacters(); 
    } 
} 
}); 

我該如何獲得keydown事件處理函數和按鈕單擊事件處理函數?

+0

基本上,你要替換Template.kanjifinder.events。 – 2013-03-13 16:16:23

回答

3

不要使用=

Template.kanjifinder.events({ 
'keydown input.txtQuery': function (evt) { 
    if (evt.which === 13) { 
    SetCharacters(); 
    } 
} 
}); 

您也可以一起在一個同時使用:在第二個代碼塊

Template.kanjifinder.events({ 
    'click input.btnOK': function() { 
     console.log("click"); 
     SetCharacters(); 
    }, 
    'keydown input.txtQuery': function (evt) { 
     if (evt.which === 13) { 
      SetCharacters(); 
     } 
    } 
}); 
+0

哦,領主!我怎麼會錯過'='* facepalm * 再次感謝@Akshat! – 2013-03-13 15:11:41