Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

13 Commits

Repository files navigation

Bindable

Light weight dependency injection for client side components. Looks for all DOM elements with a data-bindable attribute, stores references within a registry and instantiates their respective classes.

WIP

  • Cleanup docs and describe a little more behind bindable (i.e. local bindables, etc.)
  • Link to Jed's presentation
  • Wrap more tests around bindable's setup
  • Create packages for Bower and Component

Install

Describe this

Usage

As a class making use of the Bindable registry:

varToggleGroup=(function(){functionToggleGroup(el){this.el=el}ToggleGroup.prototype.dispose=function(){// Clean up your mess};returnToggleGroup})();Bindable.register('toggle-group',ToggleGroup);

As markup instantiating a class that is registered with Bindable:

<navdata-bindable="toggle-group">...</nav>

Bindable is created after the page has loaded

varbindablewindow.addEventListener('DOMContentLoaded',function(){bindable=newBindable().bindAll()// ...});

API

#bindAll

Binds all elements on the page with a data-bindable attribute with it's respective class.

varbindable=newBindable()bindable.bindAll()

#bind

TODO: Describe This!!!!

#getRefs

Returns a listing of all bindable objects on the page.

varbindable=newutensils.Bindable()bindable.bindAll()varbinded=bindable.getRefs()

#dispose

Calls the dispose method on all bindable objects and cleans out the instance of Bindable.

varbindable=newutensils.Bindable()bindable.bindAll()bindable.dispose()

Bindable.getClass

Static method for returning a class instance out of the registry from a key.

varobject=Bindable.getClass('key')

Bindable.register

Manually add a bindable object to the registry by passing a key and a class instance.

Bindable.register('my_class',newMyClass())

About

Bindable: Simple dependency injection for browser based javascript.

Resources

Stars

8 stars

Watchers

6 watching

Forks

Releases

Packages

Contributors

Languages