Reputation: 359
I am new in backbone.js. And i have to use application library for Backbone.js .
But I am not understand how to use or implement can you pls help me to use application library for Backbone.js .
Application library is: Marionette
Upvotes: 2
Views: 130
Reputation: 2921
to be honest, your question has less details than it should to provide you short answer, so the answer will be long) . So a few words about Marionette - its main task to structure your BB application, provide you some additional structure abstraction and save you from boilerplate code.
So lets start implementation.
1) Application - Its the point your application starts. You application contains from Modules, if roughly, application task is to start necessary modules, manage communication between them and render initial views.
for e.g
// instance your app
var App = new Marionette.Application;
//define regions
App.addRegions({
'main' : '#main',
'foot' : '#foot'
});
//add init function
App.addInitializer(function(){
App.main.show(new MainView);
})
2) Modules - the key part of your app. Its part of you application like some simple widget(feedback form, link list or etc.) or something more complicated, like single page app with routes, models and so on. It also coud be some services, like social networks auth, so the independent logic part of you application is module. So try to decompose your BB app on such blocks. On my practice, i used to decompose application by 2 steps - 1) get widget-based elements 2) get services.
for e.g lets define some simple mod. Let it be simple widget
App.module('starsrating', function(starsRating){
$(function(){
$('.rating').ratePlugin({
stars: 10,
onRate: function(){
///
}
})
})
});
3) Views - ItemView, CollectionView, CompositeView, Layout
Its magic wands helps you to avoid boilerplate code in your app. I strongly recommend you to read doc about it closely and begin implementation exacttly with views, usually its the weakest part in BB app.
Hope it will help to start implementation. If you need some more info, code examples, ping me.
Upvotes: 1