저는 백본에 젖은 채 젖히고 있습니다. 문제는 해결하기 쉽습니다. 2 시간마다 발사됩니다백본 이벤트가 여러 번 호출되었습니다.
myApp.views.Support = {
Form: Backbone.View.extend({
initialize: function() {
this.el = $('#support');
this._ensureElement();
},
render: function() {
if (this.$el.hasClass('support-panel')) {
// close panel
this.$el.empty();
this.$el.removeClass('support-panel');
this.$el.addClass('support-button');
}
else {
// open and populate panel
var template = _.template(myApp.utils.RenderTemplate('support/default'), {});
this.$el.removeClass('support-button');
this.$el.addClass('support-panel');
this.$el.html(template);
}
return this;
},
closePanel: function() {
alert('close event fired');
},
events: {
'click #SubmitFormButton': 'submitForm',
'click #CloseSupportPanel': 'closePanel'
},
submitForm: function (event) {
alert('form submitted: ' + $('#message'));
}
})
}
모두가 "closePanel"를 제외하고 잘 작동 : 나는 클릭 패널을 열고 닫을 때 때이 탭으로 돌아갑니다 것을 간단한 탭입니다 다음보기가 클릭 이벤트가 발생합니다. 나는 그것이 내가 빠뜨린 일종의 정리라고 생각하지만, 나는 무엇을 모르고있다.
이 방법은 효과가 있지만 "최상의"방법은 아닙니다. 나는 그 진술 뒤에 절대적으로 근거가 없다는 것을 완전히 인정한다. 아마도이 시나리오를 다루는 적절한 방법 일 것이다. 어떻게 생각해? – Matt
올바른 방법. 자바 스크립트가 작동하는 방법입니다. –