TAB navigation breaks because render replaces the DOM element.
The backbone render method is designed to work with markup of the entire view and not only changed stuff...
Given the following - I set the tabindex correctly on the html tags to specify tab order. - I navigate from field to field by using TAB on the keyboard. - I bind to the change change event calling render when ever the model state changes as so :- this.model.bind('change', this.render); - I change something in a field and tab to the next (which triggers a model change event)
Has anyone a solution to this without explicit code checking all the changed properties, and without replacing backbone(as this is not an option on the current project)
Example:
Launch the TODO app creating 2 TODOs, tab to the first TODO and press space to mark is as done. Then try to tab to the next field, instead of going to the next TODO you're back to the what needs to be done input :(
render
on a change event. Create a new function (update?) that doesn't replace the HTML entirely – Cory Danielsonchange
event on the model, pluck the ID, and focus from that. I don't think you'd need additional data;lastFocused
can be deduced from the existing data, no? If you post some of your current code, I'd be happy to put together an example. – Mathletics