/
BackBone.js By. Phil Sheperd BackBone.js By. Phil Sheperd

BackBone.js By. Phil Sheperd - PowerPoint Presentation

bery
bery . @bery
Follow
342 views
Uploaded On 2022-05-31

BackBone.js By. Phil Sheperd - PPT Presentation

What is BackBone BackBone is a Javascript Framework How is this different From jQuery or Prototype Libraries vs Framework BackBone is a way to structure your code WhyWhen should you use ID: 912193

view backbone collection model backbone view model collection extend views html template events var click lot script span demo

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "BackBone.js By. Phil Sheperd" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

BackBone.js

By. Phil Sheperd

Slide2

What is BackBone

BackBone

is a

Javascript

Framework How is this different FromjQuery or Prototype?Libraries vs FrameworkBackBone is a way to structure your code

Slide3

Why/When should you use BackBone

You should use

BackBone

to get your ‘Truth out of the DOM’

.Doesn’t make sense all the time

Slide4

Signs to use BackBone

You use a lot of data attributes in your html

You have a lot of hidden content to be displayed only on certain events happening

You ever see a line in your

js like this:$($(this).children()[1]).html().trim();

Slide5

How is a BackBone

App Structured

MCV

NOT MVC (Model, View, Controller)

ModelsData of your applicationModels generally have attributesCollectionsA collections of the modelsViewsGenerally templates rendered with underscore.js

Slide6

Model

Create a new model

by

calling

:var Question = Backbone.Model.extend({});Models can have default datadefaults: { attribute : value}

Can also have

url

of where to

save from (to advanced for

this demo)

Slide7

Collection

var Questions =

Backbone.Collection.extend

(

{ model : Question} );It is a collection of modelsThese can also have a

rootURL

but again, to

advance for this

demo

Slide8

Views

var CategoryView

=

Backbone.View.extend

({ collection : Questions, template : _.template($('#column').html())});View can be for collections or modelsTemplates are defined by underscore.js

Slide9

Views and Events and Templates

events : {

'click #fade'

:

'clear', 'click .hint_button' : "showHint", 'click .showAnswer' : 'showAnswer

}

<script type="template/text" id='

modalView

’>

<

span class='<%= answered ? "done" : ""%>' >

<%= value %>

<

/span>

<

/script>

Slide10

Rendering The View

There is one very important function in views at it is: Render

Every view has a

this.el

this.el is the element that is put in the domthis.$el is the jquery version of that element

Lets just start coding this stuff

up

MORE Resources

http://backbonejs.org

/

http://documentcloud.github.com

/backbone/

#

examples