powmedia / backbone-forms

Form framework for BackboneJS with nested forms, editable lists and validation
MIT License
2.17k stars 415 forks source link

Bind form to DOM element #509

Closed CyCJIeHok closed 8 years ago

CyCJIeHok commented 8 years ago

Hi. I have rendered DOM element I can somehow bind it to the form? Backbone.Form to monitors changes in the element.

glenpike commented 8 years ago

Hi,

Not as far as I am aware. If you're using Backbone and already have a form, you probably just want to bind change events to the input(s).

So something like this:

http://stackoverflow.com/questions/10746706/attaching-backbone-js-views-to-existing-elements-vs-inserting-el-into-the-dom/10748007#10748007

Then bind events as normal:

var myView = Backbone.View.extend({
  events: {
    'change input': 'inputHandler'
  },

  inputHandler: function(e) {
     //handle events here: 
  },

  render: function() {
  //stackoverflow stuff
  }
});