background preloader

Backbone.js | Marionette

Facebook Twitter

Marionette: Explained. Elegantly using in backbone apps. Backbone.js is my favourite modern MVC framework for client-side javascript.

Elegantly using in backbone apps

Not that I’ve seriously tried any others … simply didn’t feel the need to. The way apps are usually organised is Backbone is that data is king. A view reacts to some user action and changes some data in a model. Everybody who’s listening for that change then reacts and does something either to their view (adding something new on the screen, say) or data gets changed. Sometimes a change in data will cause the browser URL to change. Whatever, the important part is events are usually communicated through state changes. Events Despite the god-like status of models, most of your code goes into views. Data changesuser actions Listening to data changes is easiest done in the initialize function, something like so: Okay, but what about user actions? That can get unwieldy real quick … Backbone has us covered with the events hash: But what happens when you add to the mix?

Adding But this feels dirty: Events.

Archi, scaffolding, structure projets

Marionette.js. Generators, boilerplate. Tutorials. Backbone.js Tips And Patterns. Backbone.js1 is a popular open-source JavaScript “MV*” framework that has gained significant traction since its first release a little over three years ago.

Backbone.js Tips And Patterns

Although Backbone.js provides structure to JavaScript applications, it leaves a lot of design patterns and decisions up to the developer, for better or worse, and developers run into many common problems when they first begin developing in Backbone.js. Therefore, in this article, we’ll explore different design patterns that you can use in your Backbone.js applications, and we’ll look at many of the common gotchas that trip up developers. 2Applications, like buildings, are best built following known patterns. (Image: Matthew Rutledge3) Perform Deep Copies Of Objects Link JavaScript treats all primitive-type variables as pass-by-value. Var helloWorld = “Hello World”;var helloWorldCopy = helloWorld; For example, the code above will set helloWorldCopy equal to the value of helloWorld. And let’s say you create a new person object: (al) (ea)

Blogs devs

Avoiding Common Backbone.js Pitfalls. With the rise of HTML5 and the huge advancement in Javascript performance and APIs in modern browsers, single page applications are now more popular than ever.

Avoiding Common Backbone.js Pitfalls

With that, several open source frameworks and libraries were born to help us develop these somewhat complex applications. Backbone.js, while being one of the more popular choices, is also one of the smallest ones (in both terms of scope and actual byte count). So while Backbone is tremendously helpful, it does leave a lot of grunt work for us, the developers, to do ourselves. This sometimes creates a bit of friction when getting started, as we face common problems, expecting Backbone to take care of them for us, when in reality we may leave "holes" or hidden bugs in our app.

Here are some common ones, that are easily avoided, once we realize they exist.

Ext, modules, ...

Django + Backbone. Flask + Backbone.js. Developing Backbone.js Applications - By Addy Osmani (@addyosmani) Available free for open-source reading below or for purchase via the O'Reilly store.

Developing Backbone.js Applications -

Pull requests and comments always welcome. Prelude Not so long ago, “data-rich web application” was an oxymoron. Today, these applications are everywhere and you need to know how to build them. Traditionally, web applications left the heavy-lifting of data to servers that pushed HTML to the browser in complete page loads. Think of the Ajax shopping cart which doesn’t require a refresh on the page when adding an item to your basket.

The rise of arbitrary code on the client-side which can talk to the server however it sees fit has meant an increase in client-side complexity. Thankfully, there are a growing number of JavaScript libraries that can help improve the structure and maintainability of your code, making it easier to build ambitious interfaces without a great deal of effort. Target Audience Acknowledgements Credits Target Version Reading What Is MVC? Backbone.js. Backbone patterns. Building apps with Backbone.js Here, I try to document the good practices that our team has learned along the way building Backbone applications.

Backbone patterns