Question
How can you attach listeners to events in a view?

Answers

Use the “events” attribute of Backbone.View. Remember that event listeners can only be attached to child elements of the “el” property.
See example below:
SearchView = Backbone.View.extend({    initialize: function(){        this.render();    },    render: function(){        var template = _.template( $("#search_template").html(), {} );        this.$el.html( template );    },    //Attach listener to click event of the search button    events: {        "click input[type=button]": "doSearch"    },    doSearch: function( event ){        // Button clicked, you can access the element that was clicked with event.currentTarget        alert( "Search for " + $("#search_input").val() );    }});   Your Comment




More Software Questions..
What is the inputsplit in map reduce software?

What is software configuration management?

What Is Java Api For Xml-based Rpc (jax-rpc)?

How can you implement fine-grained auditing?

What is IBM’s simple explanation for Big Data’s four critical features?

What is static synchronized method in JDBC API? Give an example?

What does the NULLIF function do?

What happens if a start method is not invoked and the run method is directly invoked?

Should we override finalize method

what is the difference between mysql_fetch_array and mysql_fetch_object?

How will XML affect my document links?

Why to use Style Sheets?

What are Filters in MVC?

Can you explain Application layer in OSI model?

How to define new testplan attributes?

What are the minimum system requirements to run Photoshop? Is it possible to run Photoshop over linux?

Which oracle package is used to manage the oracle lock management services?

What is Latch Up? Explain Latch Up with cross section of a CMOS Inverter. How do you avoid Latch Up?

What is marker interface?

What types of partitioning are there for BW?



Search
Can you Answer!!
  • Q Tell me something about decoupling capacitors and explain decoupling capacitor placement.
  • Q What are the higher level APIs under development on top of JDBC currently
  • Q Who was the first Indian to be a Fellow of the Royal Society of London?
  • Q Will Water damage concrete?
  • Q How many districts does Himachal Pradesh consist?
  • Q In which session did the Congress & Muslim league came together?
  • Q The word Calendar comes from Latin and means what
  • Q Can a transparent table exist in data dictionary but not in the database physically?
  • Q "locking" a track will ensure that it cannot be changed or effected accidentally. Where is the padlock button that "locks" a track located?
  • Q Why do we use Design Pattern?
  • Q The snake crawled ______ its hole: