What would be the best way to detect onkeypress event on a div in backbonejs view?
Currently putting it in the events is not working,
events: {
"keypress div#xyz": "myFunction"
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The problem is that keyboard events are sent only to the element that has focus (for example a form input) and are not bubbled to container elements. http://api.jquery.com/keyup/
You should bind it to the exact element(s) in which text can be entered.