Skip to content

Commit

Permalink
Add bower.json and proper README
Browse files Browse the repository at this point in the history
  • Loading branch information
bensmithett committed Oct 11, 2013
1 parent 8b18036 commit d9099f2
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 20 deletions.
20 changes: 0 additions & 20 deletions LICENSE

This file was deleted.

38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,41 @@ viewloader
==========

A tiny little framework-agnostic JS bootstrapping thing.

Add `data-view` attributes to your HTML:

```html
<div data-view="dropdown">
...
</div>
```

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 }); },
// ...
};
```

Once the DOM is ready, run:

```javascript
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:

- `$el`: the jQuery-wrapped DOM element (i.e. `$(el)`)
- `el`: the DOM element

`viewloader.execute` takes an optional second argument so you can scope execution to a particular element/set of elements. This is useful if you've updated the DOM and need to re-bind behaviour to new elements.

```javascript
viewloader.execute( myApp.views, $("#updated-dom-container") );
```

## License
viewloader is released under the [MIT License](http://ben.mit-license.org/)
18 changes: 18 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "viewloader",
"main": "viewloader.js",
"version": "0.0.1",
"homepage": "https://github.com/bensmithett/viewloader",
"authors": [
"Ben Smithett <[email protected]>"
],
"dependencies": {
"jquery": ">=1.4.3"
},
"description": "A tiny tool for easily attaching JS behaviour to a HTML element",
"license": "MIT",
"ignore": [
"**/.*",
"README.md"
]
}

0 comments on commit d9099f2

Please sign in to comment.