我一直在使用backbone.js的Phonegap/Cordova 2.0應用程序,這一切都很好,直到我試圖建立一個窗體。顯示窗體,但點擊事件不會觸發鍵盤。點擊事件沒有被觸發PhoneGap/Backbone.js與Underscore.js模板
我玩過不同的事件,發現加入ontouchstart="this.focus()"
提起了鍵盤的罰款。我在視圖功能增加了一個包羅萬象把重點:
window.PageView = Backbone.View.extend({
initialize: function() {
this.template = _.template(tpl.get('page'));
},
render: function(eventName) {
$(this.el).html(this.template(this.model.toJSON()));
$('input', $(this.el)).bind('touchstart',function(event) {
$(this).focus();
});
return this;
}
});
但即使有,如果我改變bind('touchstart'...
到'click'
它不會被觸發。
我發現一對夫婦的其他職位,如:click event doesn't fire in an underscore template
這表明它與underscore.js模板過程中做但沒有什麼是很清楚的。
我想我可以在touchstart上做一個定時器函數來模擬這個,但它很神祕,所以我想知道真的發生了什麼。
謝謝。
綁定事件不是問題,因爲我可以成功綁定其他事件。它只是不會觸發點擊事件。 – Martin