Kosmetika
Kosmetika

Reputation: 21304

Backbone.js - Give a strict order of view events handlers calls

I need somehow to make my keydown event to fire before input event ALWAYS.

class RowView extends Backbone.View
    events:
      'keydown .js-field' : 'onKeydown'
      'input .js-field' : 'onInput'

Is it possible to make it call these handlers in strict order?

Upvotes: 0

Views: 109

Answers (1)

glortho
glortho

Reputation: 13200

They should always be called in that order given the event sequence in all browsers – keypress, keydown, input, keyup, etc. – but if you want to see and have more fine-grained control, you could attach the same callback to both events and then use event.type to see which one was called, and then delegate from there.

Upvotes: 1

Related Questions