さて、子ビューをレンダリングするクリックイベントを持つ親ビューがあります。この子ビュー内には、検証してから送信しようとしているフォームがあります。したがって、私の親ビューは次のようになります。
var MapView = Backbone.View.extend({
el: '.body',
template: _.template(MapTemplate),
render: function() {
...
},
events: {
'click #log-pane-title': 'loadLogView'
},
loadLogView: function() {
var eventLogView = new EventLogView({
id: properties._id
});
eventLogView.render();
}
});
そして、私の子ビューは次のようになります。
var EventLogView = Backbone.View.extend({
el: '#eventlog',
logform: new NewLogForm({
template: _.template(AddLogTemplate),
model: new LogModel()
}).render(),
render: function() {
// Render the form
$("#addtolog").html(this.logform.el);
},
events: {
'submit #addlogentry': 'test'
},
test: function() {
alert('inside eventlogview');
return false;
}
});
私が直面している問題は、test()
決して発火しないことです。デバッグの目的で、次のようにして、送信イベントが発生していることを確認しました。
$('#addlogentry').on('submit', function() {
alert( "submit firing" );
return false;
});
render()
のEventLogView
. _ それは実際にトリガーされるので、何が起こっているのか、なぜtest()
トリガーされないのかわかりません。