jumpToWave 事件只触发一次,我不明白为什么。
这是我的看法:
var WaveModalView = Backbone.View.extend({
template:_.template($('#tpl-wave-modal').html()),
events: {
'hidden': 'remove',
'click .jumpToWaveBtn':'jumpToWave'
},
jumpToWave:function(e){
e.preventDefault();
console.log("JMP")
var marker = this.model.collection.markers[this.model.id];
map.panTo(marker.getPosition());
bounceMarker(marker,1750);
},
render:function () {
var model = this.model;
var that = this;
$(this.el).html(this.template(model.toJSON()));
if(model.get('waveReviews').length > 0){
var reviewList = new WaveReviewList({model: model});
$('#waveReviews' + model.id).html(reviewList.render().el);
}
this.$("#waveSync" + model.id).click(function(e){
e.preventDefault();
if(window.me){
requestSyncWave(model.id,function(data){
window.me.fetch();
});
}
});
this.$("#waveEdit" + model.id).click(function(e){
e.preventDefault();
window.waveUnderEdit = model;
$(that.el).children(":first").modal('hide');
openWaveEditModal(model);
});
return this;
}
});
这是模板中的相关按钮:
<button class="btn btn-info jumpToWaveBtn" data-dismiss="modal" aria-hidden="true">Auf Karte
anzeigen</button>
单击按钮时,我有多个模式。每个模式只触发一次事件,之后不再记录“JMP”。