Answer the question
In order to leave comments, you need to log in
Remove error when backbone dropdown is hidden?
you need to hide the dropdown menu on click on document.
events: {
'click': function() {
this.countriesDropDownListView.toggleList();
}
},
toggleList: function() {
this.$el.toggle();
$(document).one('click', function() {this.$el.toggle()});
}
Cannot read property 'toggle' of undefined
Answer the question
In order to leave comments, you need to log in
toggleList: function() {
var el = this.$el;
el.toggle();
$(document).one('click', function() {
el.toggle();
});
}
Thanks for the answers, indeed both answers are correct, but still I will leave the code where I stopped
toggleList: function(e) {
e.stopPropagation();
this.$el.toggle();
$(document).one('click', function() {this.$el.hide();}.bind(this));
}
events: {
'click': function(e) {
this.countriesDropDownListView.toggleList(e);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question