I have two views, one of them have a search box that includes a button "Search" with id="search"
. In the second view I want when click in button "Search" make a search. But for this happens I need to get the id. How can do this?
Here the code of my second view, but not works because #search
is in the first view:
ev.views.Home = Backbone.View.extend({
events: {
'click #search' : 'searchKey',
});
All the events hash are limited to the views el
. Hence the event won't be triggered. Access the element Globally and bind the event using jquery in view's initialize.
ev.views.Home = Backbone.View.extend({
initialize:function(){
$('#search').click(this.searchKey);
}
});
Edit : this answer just solves the problem. consider Peter Wagener answer.