Submit Search
Upload
20131004 - Backbone js 介紹 by Bryan
•
Download as PPTX, PDF
•
0 likes
•
551 views
L
LearningTech
Follow
20131004 - BackboneJS 介紹_Bryan
Read less
Read more
Technology
Entertainment & Humor
Report
Share
Report
Share
1 of 12
Download now
Recommended
Mvc
Mvc
Yun-tao Chen
Mvp
Mvp
7hihi
通过Struts构建Web应用
通过Struts构建Web应用
yiditushe
前端MVC之backbone
前端MVC之backbone
Jerry Xie
Angular js 入門介紹
Angular js 入門介紹
wantingj
MobileWebAppFramework_V5_design
MobileWebAppFramework_V5_design
Jackson Tian
jQuery入門
jQuery入門
鈺棠 徐
Phalcon框架入门
Phalcon框架入门
xiaopei li 李小培
Recommended
Mvc
Mvc
Yun-tao Chen
Mvp
Mvp
7hihi
通过Struts构建Web应用
通过Struts构建Web应用
yiditushe
前端MVC之backbone
前端MVC之backbone
Jerry Xie
Angular js 入門介紹
Angular js 入門介紹
wantingj
MobileWebAppFramework_V5_design
MobileWebAppFramework_V5_design
Jackson Tian
jQuery入門
jQuery入門
鈺棠 徐
Phalcon框架入门
Phalcon框架入门
xiaopei li 李小培
程式人雜誌 -- 2015 年1月號
程式人雜誌 -- 2015 年1月號
鍾誠 陳鍾誠
twMVC#04 | ASP.NET MVC 4 新功能介紹(快速上手)
twMVC#04 | ASP.NET MVC 4 新功能介紹(快速上手)
twMVC
ASP.NET MVC 4 新功能介紹(快速上手) -twMVC#4
ASP.NET MVC 4 新功能介紹(快速上手) -twMVC#4
twMVC
JdonFramework中文
JdonFramework中文
banq jdon
ASP.NET Core MVC 2.2從開發到測試 - Development & Unit Testing
ASP.NET Core MVC 2.2從開發到測試 - Development & Unit Testing
江華 奚
Uliweb设计分享
Uliweb设计分享
modou li
Asp.net mvc網站的從無到有
Asp.net mvc網站的從無到有
Wade Huang
Js高级技巧
Js高级技巧
fool2fish
Angular.js & ASP.NET in Study4
Angular.js & ASP.NET in Study4
Kyle Shen
Angular js入门分享 by 王栋
Angular js入门分享 by 王栋
栋 王
Real World ASP.NET MVC
Real World ASP.NET MVC
jeffz
基于J2 Ee 的通用Web 信息系统框架设计与实现
基于J2 Ee 的通用Web 信息系统框架设计与实现
yiditushe
Asp.net mvc 從無到有 -twMVC#2
Asp.net mvc 從無到有 -twMVC#2
twMVC
twMVC#02 | ASP.NET MVC 從無到有
twMVC#02 | ASP.NET MVC 從無到有
twMVC
使用 ASP.NET MVC 開發SPA網站-微軟實戰課程日
使用 ASP.NET MVC 開發SPA網站-微軟實戰課程日
twMVC
twMVC#01 | ASP.NET MVC 的第一次親密接觸
twMVC#01 | ASP.NET MVC 的第一次親密接觸
twMVC
Single-Page Application Design Principles 101
Single-Page Application Design Principles 101
Jollen Chen
Jswebapps
Jswebapps
jay li
Asp.net mvc 基礎
Asp.net mvc 基礎
Gelis Wu
Backbone js and requirejs
Backbone js and requirejs
Chi-wen Sun
vim
vim
LearningTech
PostCss
PostCss
LearningTech
More Related Content
Similar to 20131004 - Backbone js 介紹 by Bryan
程式人雜誌 -- 2015 年1月號
程式人雜誌 -- 2015 年1月號
鍾誠 陳鍾誠
twMVC#04 | ASP.NET MVC 4 新功能介紹(快速上手)
twMVC#04 | ASP.NET MVC 4 新功能介紹(快速上手)
twMVC
ASP.NET MVC 4 新功能介紹(快速上手) -twMVC#4
ASP.NET MVC 4 新功能介紹(快速上手) -twMVC#4
twMVC
JdonFramework中文
JdonFramework中文
banq jdon
ASP.NET Core MVC 2.2從開發到測試 - Development & Unit Testing
ASP.NET Core MVC 2.2從開發到測試 - Development & Unit Testing
江華 奚
Uliweb设计分享
Uliweb设计分享
modou li
Asp.net mvc網站的從無到有
Asp.net mvc網站的從無到有
Wade Huang
Js高级技巧
Js高级技巧
fool2fish
Angular.js & ASP.NET in Study4
Angular.js & ASP.NET in Study4
Kyle Shen
Angular js入门分享 by 王栋
Angular js入门分享 by 王栋
栋 王
Real World ASP.NET MVC
Real World ASP.NET MVC
jeffz
基于J2 Ee 的通用Web 信息系统框架设计与实现
基于J2 Ee 的通用Web 信息系统框架设计与实现
yiditushe
Asp.net mvc 從無到有 -twMVC#2
Asp.net mvc 從無到有 -twMVC#2
twMVC
twMVC#02 | ASP.NET MVC 從無到有
twMVC#02 | ASP.NET MVC 從無到有
twMVC
使用 ASP.NET MVC 開發SPA網站-微軟實戰課程日
使用 ASP.NET MVC 開發SPA網站-微軟實戰課程日
twMVC
twMVC#01 | ASP.NET MVC 的第一次親密接觸
twMVC#01 | ASP.NET MVC 的第一次親密接觸
twMVC
Single-Page Application Design Principles 101
Single-Page Application Design Principles 101
Jollen Chen
Jswebapps
Jswebapps
jay li
Asp.net mvc 基礎
Asp.net mvc 基礎
Gelis Wu
Backbone js and requirejs
Backbone js and requirejs
Chi-wen Sun
Similar to 20131004 - Backbone js 介紹 by Bryan
(20)
程式人雜誌 -- 2015 年1月號
程式人雜誌 -- 2015 年1月號
twMVC#04 | ASP.NET MVC 4 新功能介紹(快速上手)
twMVC#04 | ASP.NET MVC 4 新功能介紹(快速上手)
ASP.NET MVC 4 新功能介紹(快速上手) -twMVC#4
ASP.NET MVC 4 新功能介紹(快速上手) -twMVC#4
JdonFramework中文
JdonFramework中文
ASP.NET Core MVC 2.2從開發到測試 - Development & Unit Testing
ASP.NET Core MVC 2.2從開發到測試 - Development & Unit Testing
Uliweb设计分享
Uliweb设计分享
Asp.net mvc網站的從無到有
Asp.net mvc網站的從無到有
Js高级技巧
Js高级技巧
Angular.js & ASP.NET in Study4
Angular.js & ASP.NET in Study4
Angular js入门分享 by 王栋
Angular js入门分享 by 王栋
Real World ASP.NET MVC
Real World ASP.NET MVC
基于J2 Ee 的通用Web 信息系统框架设计与实现
基于J2 Ee 的通用Web 信息系统框架设计与实现
Asp.net mvc 從無到有 -twMVC#2
Asp.net mvc 從無到有 -twMVC#2
twMVC#02 | ASP.NET MVC 從無到有
twMVC#02 | ASP.NET MVC 從無到有
使用 ASP.NET MVC 開發SPA網站-微軟實戰課程日
使用 ASP.NET MVC 開發SPA網站-微軟實戰課程日
twMVC#01 | ASP.NET MVC 的第一次親密接觸
twMVC#01 | ASP.NET MVC 的第一次親密接觸
Single-Page Application Design Principles 101
Single-Page Application Design Principles 101
Jswebapps
Jswebapps
Asp.net mvc 基礎
Asp.net mvc 基礎
Backbone js and requirejs
Backbone js and requirejs
More from LearningTech
vim
vim
LearningTech
PostCss
PostCss
LearningTech
ReactJs
ReactJs
LearningTech
Docker
Docker
LearningTech
Semantic ui
Semantic ui
LearningTech
node.js errors
node.js errors
LearningTech
Process control nodejs
Process control nodejs
LearningTech
Expression tree
Expression tree
LearningTech
SQL 效能調校
SQL 效能調校
LearningTech
flexbox report
flexbox report
LearningTech
Vic weekly learning_20160504
Vic weekly learning_20160504
LearningTech
Reflection & activator
Reflection & activator
LearningTech
Peggy markdown
Peggy markdown
LearningTech
Node child process
Node child process
LearningTech
20160415ken.lee
20160415ken.lee
LearningTech
Peggy elasticsearch應用
Peggy elasticsearch應用
LearningTech
Expression tree
Expression tree
LearningTech
Vic weekly learning_20160325
Vic weekly learning_20160325
LearningTech
D3js learning tips
D3js learning tips
LearningTech
git command
git command
LearningTech
More from LearningTech
(20)
vim
vim
PostCss
PostCss
ReactJs
ReactJs
Docker
Docker
Semantic ui
Semantic ui
node.js errors
node.js errors
Process control nodejs
Process control nodejs
Expression tree
Expression tree
SQL 效能調校
SQL 效能調校
flexbox report
flexbox report
Vic weekly learning_20160504
Vic weekly learning_20160504
Reflection & activator
Reflection & activator
Peggy markdown
Peggy markdown
Node child process
Node child process
20160415ken.lee
20160415ken.lee
Peggy elasticsearch應用
Peggy elasticsearch應用
Expression tree
Expression tree
Vic weekly learning_20160325
Vic weekly learning_20160325
D3js learning tips
D3js learning tips
git command
git command
20131004 - Backbone js 介紹 by Bryan
1.
Backbone JS 介紹 2013/10/04 Bryan
Lin
2.
Agenda Introduction Model
View
3.
Introduction Javascript MVC
(Model-View-Controller) 框架 提供了非常簡單的方式創建模型 (model) 和視圖 (view) 幫助開發者可以很自然而 然的明確區隔使用者操作介面 (view) 的行為及背後資料處理 (model) 的邏輯 Backbone.js 的 model 是透過 observer pattern 的方式,讓 view 可以直接監聽 model 上的任何 event ,並且立刻更新 view 本身 支援 jQuery 或 Zepto 操作 DOM 提供支援 RESTful JSON interface 的 API
4.
Model Model 顧名思義是用來存放資料的類別,使用
Backbone 的 model 的好處是可以 很容易地和其他 Backbone 的類別作互動。 Backbone.js 的 constructor 的名字是 initialize Person = Backbone.Model.extend({ initialize: function() { console.log('hello world!'); } });
5.
Model 可以直接新增 model
的屬性: var person = new Person({ name: "Joe", height: "6 feet" });
6.
Model 取出剛才新增的屬性: person.get(‘name’)
7.
Model 針對屬性給予預設值: Person =
Backbone.Model.extend({ initialize: function() { console.log("hello world!"); }, defaults: { name: "Scott", height: "unknown" } });
8.
Model 綁定change 事件(change:name中間不可包含空格) Person
= Backbone.Model.extend({ initialize: function() { console.log("hello world!"); this.bind("change:name", function() { console.log(person.get('name')); }); } //... });
9.
Model 檢查 model
的正確性 Person = Backbone.Model.extend({ initialize: function() { console.log('hello world!'); this.bind("change:name", function() { console.log(persion.get('name')); }); this.bind("error", function(model, error) { console.log('error'); }); }, validate: function( attributes ) { if (attributes.name == 'kenny' ) { return 'Kenny is the founder of babylife'; } }, });
10.
View initialize :View
的建構子 el :View 對應到的 DOM 物件 event:註冊事件 template 是指繪製 View 的時候可套用的template render: 操作改變 el 的外觀
11.
View var myView =
Backbone.View.extend({ initialize: function () { console.log('create view'); }, el: '#container', events: { "click": "render" }, template: $('#list-template').children(), render: function() { var data = this.model.get('data'); for (var i=0, l=data.length; i<l; i++) { var a = this.template.clone().find('a'); var li = a.attr('href', data[i].href) li = li.text(data[i].text).end(); this.$el.find('ul').append(li); } } });
12.
範例程式 http://jsfiddle.net/rightson/xp4pD/
Download now