Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

backbone-elements

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-elements

Backbone.View shortcut for obtaining child element references

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

backbone-elements

Build Status

Tested with Backbone 1.1.2

This library allows you to easily define and use child elements within your Backbone views:

class View extends Backbone.View
  elements:
    ".status": "status"
    ".child-element > div": "childDiv"

  events:
    "click a.another-div": "_clickHandler"

  initialize: ->
    super // parent initialize() calls @refreshElements()
    console.log 'started'

  # use the references in functions
  _clickHandler: ->
    @$status.text "clicked"
    @$childDiv.remove()

    @refreshElements() # refresh element references

You can change the default element prefix too:

class View extends Backbone.View
  elementPrefix: ''

  elements:
    ".status": "status"
    ".child-element > div": "childDiv"

  events:
    "click a.another-div": "_clickHandler"

  initialize: ->
    super // parent initialize() calls @refreshElements()
    console.log 'started'

  # use the references in functions
  _clickHandler: ->
    @status.text "clicked"
    @childDiv.remove()

    @refreshElements() # refresh element references

node.js

Install using npm:

$ npm install backbone-elements

Browser

Use bower:

$ bower install backbone-elements

Building

To build the code and run the tests:

$ npm install -g gulp
$ npm install
$ gulp

Contributing

Contributions are welcome! Please see CONTRIBUTING.md.

License

MIT - see LICENSE.md

Keywords

FAQs

Package last updated on 24 Mar 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc