BackboneJS事件处理程序
function alertTest(){ alert('alertTest has fired.');}
Views.Profile = Backbone.View.extend({
el: '.list-profile-wrapper',
events: {
'click ' : 'testmtd',
},
initialize: function() {
alert("this is in init");
},...
问题的背景:这是在WordPress网站上 . 我有一个UnderscoreJS模板,当用户点击分页编号时,该模板加载了AJAX . 此UnderscoreJS模板中包含"list-profile-wrapper"类,但不会触发BackboneJS事件处理程序 . 由于未显示警报消息,因此初始化函数甚至不会被触发 . This only happens with page templates that are loaded with AJAX. 具有类似模板但未加载AJAX的页面不会遇到此问题 .