Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Smithett committed Oct 11, 2013
1 parent d9099f2 commit 354e30c
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
viewloader
==========
Viewloader is a tiny little framework-agnostic JS bootstrapping thing that lets you attach JS behaviour to a HTML element using data attributes.

A tiny little framework-agnostic JS bootstrapping thing.
## How to use it

Add `data-view` attributes to your HTML:

Expand All @@ -16,15 +15,15 @@ Create a object for your app that lists setup functions for each type of view.
```javascript
myApp.views = {
dropdown: function( $el ) { $el.fancyDropdown(); },
chatWindow: function( $el, el ) { new ChatWindowView({ model: new ChatWindow, el: el }); },
// ...
chatWindow: function( $el, el ) { new ChatWindowView(); },
// ... etc etc
};
```

Once the DOM is ready, run:

```javascript
viewloader.execute( myApp.Views );
viewloader.execute( myApp.views );
```

viewloader will find every element on the page with a `data-view` attribute and call its setup function with 2 arguments:
Expand Down

0 comments on commit 354e30c

Please sign in to comment.