user350325
user350325

Reputation: 1455

Binding jquery-ui events to backbone events

I have a backbone view set up like so:

MyView = Backbone.View.extend({
    events: {
        'click' : 'clickOnitHandler',
        'stop' : 'dropHandler'
    },

// Rest of class

What I would like to do here is hook a jquery-ui event for the draggable control.

This would usually be done like so (with jquery):

 $( "#draggable" ).draggable({
      start: function() {
         // stuff
      },
 });

So this would go in the render() method of the backbone view, which doesn't seem quite right. I would prefer it to be declared in the events array for the view.

But not sure how to make it accessible here.

Upvotes: 1

Views: 630

Answers (1)

user350325
user350325

Reputation: 1455

I fixed this. Simply like this.

MyView = Backbone.View.extend({
    events: {
        'click' : 'clickOnitHandler',
        'dragstop' : 'dropHandler',
    },

Upvotes: 1

Related Questions