https://github.com/knowledgecode/jquery-view.js
a jQuery plugin that provides a "V" of MVC framework on the client-side JavaScript
https://github.com/knowledgecode/jquery-view.js
Last synced: 9 months ago
JSON representation
a jQuery plugin that provides a "V" of MVC framework on the client-side JavaScript
- Host: GitHub
- URL: https://github.com/knowledgecode/jquery-view.js
- Owner: knowledgecode
- License: mit
- Created: 2013-01-12T09:23:57.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2013-01-12T15:13:50.000Z (almost 13 years ago)
- Last Synced: 2025-01-30T19:52:26.985Z (11 months ago)
- Homepage:
- Size: 152 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jQuery-View.js
jQuery-View.js is a jQuery plugin. Work in jQuery or other compatible library (ex. jQMobi, Zepto).
"View" of jQuery-View means "V" of MVC framework, It is also syntax sugar of "on" and "off" methods for event bindings.
## Usage
Add the jquery-view.js below the jQuery in your html.
Then, the "view" object is added in jQuery.
It has two methods which are "on" and "off".
### $().view.on(object)
To bind events is below.
var events = {
'ready': function () {
console.log('dom loaded');
},
'load@window': function () {
console.log('window loaded');
},
'click@document': function () {
console.log('document clicked');
},
// This code doesn't work in less than IE9. Use "ready" instead.
'DOMContentLoaded@document': function () {
console.log('document DOMContentLoaded');
},
'click@.menu input': function (evt) {
evt.stopPropagation();
console.log(evt.srcElement.value + ' clicked');
}
};
// Register events
$().view.on(events);
The syntax is "eventname" + "@" + "selector".
Not accepted anything that does not conform to this syntax. However, when use a "DOMContentLoaded" event, use "ready" instead.
### $().view.off(object)
To unbind events is below.
// Unregister events.
$().view.off(events).
## License
jQuery-View is available under the terms of the MIT license.