You can do this in the view initialize() function:
_.bindAll(this, 'on_keypress');
$(document).bind('keypress', this.on_keypress);
More Related Contents:
- Destroy or remove a view in Backbone.js
- Backbone: event lost in re-render
- Backbone 0.9.9: Difference between listenTo and on
- Backbone View: Inherit and extend events from parent
- What does `void 0` mean? [duplicate]
- How to override Backbone.sync?
- Why define an anonymous function and pass it jQuery as the argument?
- Backbone.js Empty Array Attribute
- Backbone: Why assign `$(‘#footer’)` to `el`? [duplicate]
- External template in Underscore
- Getting Chrome to prompt to save password when using AJAX to login
- How to load bootstrapped models in Backbone.js while using AMD (require.js)
- Backbone.js : repopulate or recreate the view?
- Ways to save Backbone.js model data?
- “Single-page” JS websites and SEO
- Backbone.js and pushState
- Backbone.js model.get() returning ‘undefined’ even though I can see the attributes in console.log
- How to handle initializing and rendering subviews in Backbone.js?
- Backbone.js get and set nested object attribute
- In Javascript, what does this underscore mean?
- correctly implement backbone comparators
- The collection nested inside firebase collection’s model doesn’t have add function
- Backbone.View “el” confusion
- Accessibility and all these JavaScript frameworks
- start javascript code with $(function, etc
- What is the purpose of backbone.js?
- What is the difference between these Backbone/Underscore .bind() methods?
- Extending React.js components
- Uncaught SyntaxError: Failed to execute ‘querySelector’ on ‘Document’
- Super in Backbone