13.07.2015 Views

Modern Web Applications with Flask and Backbone.js

Modern Web Applications with Flask and Backbone.js

Modern Web Applications with Flask and Backbone.js

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Backbone</strong> - Launching it all●●We initialize our main view <strong>and</strong> pass to it the dom element it is responsiblefor <strong>and</strong> the collectionIn general it is easier to maintain views that don't expect dom elements tobe already present or models that are on a expected global (principle ofleast privilege)Existing DOM:Double-click to edit a todoBased on the work of Addy OsmaniPart of TodoMVCModified by Yaniv Ben-Zaken (@cizei)app.coffee code:$ ->jj.app = new jj.AppViewel : $('#todoapp')collection : new jj.TodoCollectionThis all the HTML <strong>and</strong>JS you have in orderto launch the app. Allthe rest is in templateswhich get renderedafter by code this 4 <strong>js</strong>lines launch.<strong>Backbone</strong>.history.start()

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!