New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

backbone-bind

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

backbone-bind

Super simple 2-way binding for Backbone Views

0.2.0
latest
Source
npm
Version published
Maintainers
1
Created
Source

Backbone Binding

Build Status

Super simple 2way binding for Backbone views.

This plugin requires browserify, but feel free to open PR or issues if you want to use the plugin with something else.

Install

npm i -S backbone-bind

Usage

var binding  = require('backbone-bind');
var Backbone = require('backbone')
var model    = require('./model');

// bind typical input view with this.model
var View = Backbone.View.extend({
  tagName: 'input',
  bind: binding
  render: function() {
    this.bind('title');
    return this;
  }
});

var view = new View({
  model: model
});

$('body').append(view);

Options

You can use either bind(options) or bind(field, options), as you prefer.

options.$el

Default value: this.$el

jQuery element that you will bind.

options.field

Name of model property that you will bind.

options.attr

Default value: val

Represents input value. (checked, val, innerText, etc).

options.direction

Default value: <>

Represents binding direction (model <-> element). Only < and > symbols make sence, but model <-> element is better to understand.

options.events

Default value: keydown

List of bound events like change, keypress, keydown...

options.model

Default value: this.model

Backbone model that you will bind.

Licence

MIT

Keywords

backbone

FAQs

Package last updated on 24 Feb 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts