33. BACKBONE MODELS
Make a model subclass using .extend( )
var
Property
=
Backbone.Model.extend({
star:
function()
{
this.set("starred",
!this.get("starred"));
this.save();
}
});
(code in this presentation is from the book, & final versions of sample
apps are @ github.com/pselle/choosing-javascript-framework)
38. BACKBONEVIEWS
Using a view with a model
var
myHouse
=
new
Property({
location:
"middle
of
our
street",
noiseLevel:
"usually
quite
loud"
});
var
propertyView
=
new
PropertyView({
model:
myHouse
});
propertyView.render()
document.body.appendChild(propertyView.el);
39. BACKBONEVIEWS
<div
class="property">
<h1>1123
Sunny
Road</h1>
<h2>37890</h2>
<img
src="/shared/images/
andrewmalone_house.jpg">
<p>This
is
a
fantastic
house!</p>
<p>Asking
price:
230000</p>
<button
class="pure-‐button
star">Save
as
favorite</button>
</div>
48. WEAKNESSES
• Recent rise to prominence = less time in prod
• High lock-in with writing behavior in markup
• Skeptics for future roadmap/Google backing
• 1.3 dropped IE8 support, some teams stuck in
older version now (abandonware fears)
66. WEAKNESSES
• SometimesTOO much information
• “Right” way to do things = difficult to get up to
speed quickly
• Not as pervasive as other two major frameworks
77. DETOUR
Web components are comprised of multiple
standards that are not yet implemented across
browsers:
Custom elements, HTML imports, templates, and
shadow DOM
http://webcomponents.org/
99. EVALUATIONTOOLS
• Spreadsheet for ranking: http://bit.ly/1g6kDSS
• Rank frameworks according to business, technical,
and team criteria
• Wharton DevTap:
http://technology.wharton.upenn.edu/devtap/