1.1.0 • Published 9 years ago

backbone-model-editor v1.1.0

Weekly downloads
11
License
-
Repository
github
Last release
9 years ago

Backbone Model Editor

Easily edit your backbone models with inputs, textareas, date pickers, and more.

npm.io

preview

Creating a typical app requires various forms with inputs. This plugin makes creating inputs, selects, notes fields and others simple.

Rich text editor available with Redactor plugin


Example use

this.editor = new ModelEditor({
    model:this.model, 
    el:this.el,
    defaultOpts: {	// default opts for each editor element
    	w: 120,
    	placeholder: 'auto' // create place
    	btns: true	// give inputs their own save/cancel buttons
    }
});

this.editor.insert('input', 'model_key');
this.editor.insert('input', 'model_key', {w:250});
this.editor.insert('input', 'model_key', {validate: 'Number'});

Then when you want to save the changes, call:

this.editor.save();

If you want the model to save automatically whenver an input changes, add "autoSave" option

this.editor = new ModelEditor({
    model:this.model, 
    el:this.el, 
    autoSave:true
});