Go to http://github.com/daytona/ignition/downloads for downloads.
Ignition is a jQuery-based mini-framework for developing JavaScript applications using the MVC (Model/View/Controller) pattern.
Ignition is extendable through "Modules", which in the default distribution includes a URL manager and a history dispatcher (for triggering events when the location hash changes.)
Please see the API documentation for detailed usage.
Initialize the Ignition object:
var $i = new Ignition({ modules: ['UrlManager', 'HistoryDispatcher'] });
Add a location hash match to the history dispatcher, for #articles/1
(where 1
is an arbitrary Article ID):
$i.addRoute('articles/(\d+)', function(article_id) {
$i.c.Articles.show(article_id);
});
Add a JSON URL to the URL manager, for getting Article information:
$i.addUrl('article', '/articles/:id.json');
Create an Article model, extending the base Model object:
The Model will handle the fetching of data, using the .json
method from the base object.
$i.m('Article', {
find_by_id: function(id, callback) {
this.json($i.getUrl('article', { id: id }), { success: callback });
}
});
Create an Articles controller, extending the base Controller object:
The controller will handle events, in this case a change in the location hash.
$i.c('Articles', {
show: function(id) {
$i.m.Article.find_by_id(id, $i.v.Articles.show);
}
});
Create an Articles view, extending the base View object:
The view will handle the data returned from the model's JSON call, generating DOM elements and inserting them into the document.
$i.v('Articles', {
show: function(data) {
var list = $('<ul id="articles"></ul>');
for (var i = 0; i < data.articles.length; i++) {
var article = data.articles[i];
var listItem = $('<li><a href="'+article.url+'">'+article.title+'</a></li>');
list.append(listItem);
}
$('body').append(list);
}
});
You can use the included Makefile to create production-ready files. You need to have Java installed in order for the build scripts to be able to run.
Building the default version (uncompressed + minified):
make
Compressed with /packer/:
make pack
Generate documentation files using jsdoc-toolkit:
make jsdoc
The build scripts are adapted from jQuery's ditto.
Ignition is dual licensed under the MIT and GPL licenses.
Ignition was inspired by Jamal, but was written using original code. It was originally developed for use in various internal projects by Daytona Communication AB, a digital communications agency in Stockholm, Sweden.
For more information, API documentation and end-user downloads, please see the project page at Daytona.se.
- Johan Sahlén johan.sahlen@daytona.se / johan.sahlen@gmail.com