切り替えることができるタブが3つあります。タブの1つとして、コントローラーに送信できるフォーム/ビューをバックボーンで生成します。問題は、タブを切り替えて、フォームを生成するタブをクリックしてから[送信]をクリックすると、コントローラーに複数のAJAX呼び出しを送信することです。
addPlace: function(e) {
if(!this.isSearch){
this.add = new add({
model: this.model,
attachPoint: this.$("div.addAPlaceForm")
});
$('.add_to_place').addClass("hidden");
$('.matchingWrapper').addClass("hidden");
this.add.render();
this.add.on("place:selected", this.placeSelect, this);
this.isSearch = true;
}
}
//this.add.render()
render: function(e){
this.$el.html(this.addPlaceForm({
place: this.model
}));
view.prototype.render.call(this);
}
ユーザーがフォームを生成しない他のタブの1つに切り替えると、次の機能が実行されます。
addPlacebacklink: function(e) {
this.add.undelegateEvents();
this.add.unbind();
$("div.addAPlaceForm").html("");
this.isSearch = false;
}
私はあなたがそうすることになっていることを読みましたunbind
、undelegateEvents
しかし、私はまだ私のコントローラーへの複数のAJAX呼び出しを見ます。タブを複数回切り替えても1つのフォームのみを送信できるようにBackboneを設定するにはどうすればよいですか?