- Simple easy to use and intuitive library.
- No dependencies.
- Can save/load Model to/from JSON with/without model meta data.
- Can attach custom meta-data to properties that can be persisted with model.
- Supports models defined by a remote resource with the ability to periodically refresh.
- remote model has option to use JSONP in the event of CORS issues.
- Can register on change events with any single property or group of properties.
- Model change events bubble up.
- Can define and trigger custom events.
- Can suppress change event notification.
- Can batch actions into a transaction.
- Transaction callbacks can be easily optimized.
- Can tie validation methods to models and properties.
- Can flag any property value to not be persisted to JSON.
- Can retrieve FormattedValues using a custom defined Formatter.
- Can enable logging to flag incorrect uses of api to the console.
- Native browser Support for all browsers that support ECMA5 including and tested on IE9, Firefox 4+, Safari 5.1.4+, Chrome 7+, Opera 12+ without a shim library.
- Works on non-ECMA5 browser with use of a shim library. Specifically tested on IE8 with es5-shim.
- Compatible with the CommonJS module format and is usable as a Node module.
- Compatible with AMD module loaders like requirejs.
modeljs works on all browsers that support ECMAScript 5th Edition (December 2009, http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf). It has been manually tested on IE9, Firefox 14+, Safari 5.1.4 and Chrome 21+. To see if it work on a specify browser version of your choice, run the unit tests(test/ModelTest.html). To support older non ECMA5 browsers using a shim library like es5-shim. Modeljs has been successfully tested on IE8 with the es5-shim library.
Clone the repo,
git clone git://github.com/dgeorges/modeljs.git, or download the latest release
To use modeljs in your application copy src/model.js to an appropriate location and include it in your HTML like so:
If your doing server side development in Node, you can import it like so:
var Model = require("/path/to/model.js");
Or using npm install
npm install modeljs
var Model = require("modeljs");
A couple of example pages have been created to show how to use modeljs. They can be found in the /test/example folder
- New sandbox enviornment on jsFiddle here.
- tableWidget.js Shows how a table widget can be created with model js.
- example.html Shows how to integrate the table widget on your page and is followed by a tutorial of the modeljs api.
- knockoutExample.html Shows how easy it is to build a binding library on top of modeljs that behaves like the popular knockoutjs library. The example is almost identical to the knockoutjs introduction example.
Documentation is generated by YUIdoc and can be viewed by cloning the repo or downloading the source and viewing doc/index.html.
For more information visit modeljs's wiki