How to connect an event handler in basic forms

I am using the Backbone form - https://github.com/powmedia/backbone-forms .

In several fields I use a special template for a specific field. Let's say something like this

Now let's say that I want to bind the click event handler to Add a month. What is the best way to achieve this. I see that Backbone.Form extends Backbone.View, which accepts an event object. But when I do this, new Backbone.Form () it does nothing.

+4
source share
1 answer

You should be able to extend the Backbone.Form view to add your own custom events, for example

Backbone.Form.extend({
    events: _.extend(this.events, {
      'click .add-month': 'onClickAddMonth' 
    }),

    onClickAddMonth: function(e){
       // do something
    }
})
+1
source

All Articles