TIY-LR-FEE-2015-June / assignments

0 stars 3 forks source link

6.2-backbone.js - Alia Borroho #169

Open aliaborroho opened 9 years ago

aliaborroho commented 9 years ago

Some key takeaways from the reading:

*Using Models

-It defines a RESTful URL for his model to sync with, and...It defines default attributes for his model. Default attributes are useful for representing API data composition within your front-end code. Also, these defaults guarantee that your model is always fully formed, even before loading its data from the server. -When you extend a backbone component, you always get a back a constructor function. That is a very important take away, which means we HAVE to create an instanceof the component before we can use it. *Views

A view defines a render method. This method generates HTML from its data source, and installs that markup into the view's container element. A view binds event listeners to its model. Any changes to the model should trigger the view to re-render. -When a view is instanced, Backbone will configure an $el property for us––this is a jQuery object wrapping the view's attached container element. This reference provides a convenient way to work with the container element using the jQuery API. Not only that, which means, bb.js encourages efficient DOM practices using jQuery. Rather than performing large and expensive operations across the entire HTML document, Backbone views provide a $ method that performs jQuery operations locally within the view's container element: therefore these localized jquery take a away all of the fluff that you normally have to deal with when dealing with large amounts of code throughout your HTML

*Rendering with Templates

Using a parsed template greatly simplifies the render method, especially as the size and complexity of the rendering increases. Also note that our template function is generated once and cached as a member of the view class. Generating template functions is slow, therefore it's best to retain a template function that will be used repeatedly.

***Seems like the biggest takeaway is that Backbone makes javascript easier to write, and makes it easy for the view to react to specific changes when you have a huge piece of html, you declare events with out having to worry about their specific render order

*

aliaborroho commented 9 years ago

can you elaborate on what they meant by CRUD and can we also talk about Underscore and Jquery, they got a bit blended in the teachings of the two, when they were trying to explain it