Java Questions
Java Questions

Reputation: 7953

How to do some changes to the html control based on focus events using backbone

I have a some html controls like input etc. I would like to update some status based on the focus made to the control

for example:

I would like to find a input id who gets the focus.

I tries some thing like the below but it keeps calling the method.

events :{
  'focus #input' : "updateCurrentCell"
},

updateCurrentCell: function(event) {
  alert('updateCurrentCell called');
  // Update the current cell.
} 

what is the wrong here i am doing?

Upvotes: 0

Views: 186

Answers (1)

David Sulc
David Sulc

Reputation: 25994

In updateCurrentCell, try adding a console.log message to make sure it's getting called repeatedly, and that you're not having an issue with being unable to close the alert box.

But if the function keeps getting called, it's because the input field keeps regaining focus. This could happen if you have some code forcing the focus on "#input" that gets executed each time it loses focus.

But without a jsFiddle reproducing the problem, it will be difficult to diagnose...

Upvotes: 1

Related Questions