I feel I'm missing a very basic point in backbone subview rendering (I've already read about it of course), here is my simple problem.
Here is the html:
<div id="activewindow> </div>
That's it. I render the activewindow view, no problem. When I click on some button it creates and render the modelView. Here is the html of the modalView:
<div id='modal'>
<div class='modalwindow'>
<div class="modalHeader">
<div class='closeModal' data-translate-id="closeModal"></div>
<img class='closeModal' src="./resources/images/close.png"> </img>
</div>
</div>
</div>
The problem is that when I click the close button in the modalView it doesn't trigger the closeModal function. (no console.log neither remove). Below the modalView code.
define('modalView', [
'backbone',
'text!views/modalView/destinationTemplate.html'
], function(Backbone, DestinationTemplate) {
var ModalView = Backbone.View.extend({
el:'#modal',
template: _.template(DestinationTemplate),
events: {
'mouseup .closeModal': 'closeModal'
},
initialize: function(data) {
_.bindAll(this,'render','closeModal');
console.log(data.destinationId);
this.render();
},
render: function() {
$('#activewindow').append(this.template());
},
closeModal: function() {
console.log("REMOVE!!");
this.remove();
}
});
return ModalView;
});
Thanks for your help.