SlideShare une entreprise Scribd logo
1  sur  17
JAVASCRIPT MVC WITH
      EMBER.JS
    @LASERJI 2012-06-12
WHAT IS MVC ?

Model + View + Controller
MODEL

var Person = {
     name: “”,
     say: function(thing){
            alert(“fuck this “ + thing + “!”);
     }
};

var person = new Person();
VIEW

We call {{somebody}} as BIG HOLE !!!

{{#if person}}
        Welcome back <b>{{name}}</b> !
{{/if}}
CONTROLLER

(function($, exports){
      var mod = {};
      mod.doSomething = function(){
            // do something
      };
      mod.load = function(){
            this.view = $(“#view”);
      };
})(jQuery, window);
JAVASCRIPT MVC LIBRARIES

•   Backbone.js
•   Ember.js (SproutCore 2.0)
•   Spine.js
•   JavaScriptMVC
•   Sammy.js
•   YUILibrary
•   KnockoutJS
•   Angular.js
•   Fidel.js
•   ExtJS
•   http://www.infoq.com/cn/news/2012/05/js-mvc-
    framework
EMBER.JS

• Ember is a JavaScript framework for creating
  ambitious web applications that eliminates
  boilerplate and provides a standard application
  architecture.
• Formerly known as AmberJS – formerly known as
  SprouteCore 2
• Emberjs.com
• Ember.js VS. Backbone.js
CREATING A NAMESPACE

window.App = Ember.Application.create();

window.App = Ember.Application.create({
    rootElement: '#sidebar'
});

// namespace & event handler
THE EMBER OBJECT MODEL

Person = Ember.Object.extend({
  say: function(thing) {
    alert(thing);
 }
});

var person = Person.create();
person.say("Hello") // alerts "Hello"
THE EMBER OBJECT MODEL

// Passing in an object
var tom = Person.create({
  name: "Tom Dale",
  helloWorld: function() {
    this.say("Hi my name is " + this.get('name'));
  }
});
tom.helloWorld() // alerts "Hi my name is Tom Dale"
THE EMBER OBJECT MODEL

// Reopening Classes and Instances
Person.reopen({
  isPerson: true
});
Person.create().get('isPerson') // true

Person.reopen({
  // override `say` to add an ! at the end
  say: function(thing) {
    this._super(thing + "!");
  }
});
COMPUTED PROPERTIES
Person = Ember.Object.extend({
  // these will be supplied by `create`
  firstName: null,
  lastName: null,
  fullName: function() {
    var firstName = this.get('firstName');
    var lastName = this.get('lastName');
   return firstName + ' ' + lastName;
  }.property('firstName', 'lastName')
});
var tom = Person.create({
  firstName: "Tom",
  lastName: "Dale"
});
tom.get('fullName') // "Tom Dale"
BINDINGS

App.president = Em.Object.create({
    name: "Obama”
});

App.country = Em.Object.create({
    presidentNameBinding: 'App.president.name'
});

App.country.get('presidentName’); // “Obama"
EVENT HANDELER

App.ListingView = Ember.View.extend({
    templateName: 'edit',
    edit: function(event) {
      alert('Edited')
    }
});
EVENT HANDELER

App.ClickableView = Ember.View.extend({
    click: function(evt) {
       alert("ClickableView was clicked!");
    }
});
OTHER RESOURCES

• http://www.adobe.com/devnet/html5/articles/flam
  e-on-a-beginners-guide-to-emberjs.html
• http://emberjs.com/documentation/
• http://www.andymatthews.net/read/2012/03/07/G
  etting-Started-With-EmberJS
• http://ngauthier.com/2012/02/playing-with-
  ember.html
• http://emberjs.tumblr.com/
THANK YOU !

Contenu connexe

Tendances

iPhone Appleless Apps
iPhone Appleless AppsiPhone Appleless Apps
iPhone Appleless AppsRemy Sharp
 
Ember.js for Big Profit
Ember.js for Big ProfitEmber.js for Big Profit
Ember.js for Big ProfitCodeCore
 
Webapps without the web
Webapps without the webWebapps without the web
Webapps without the webRemy Sharp
 
Mojolicious, real-time web framework
Mojolicious, real-time web frameworkMojolicious, real-time web framework
Mojolicious, real-time web frameworktaggg
 
Managing State in Single Page WebApps with Ember.js
Managing State in Single Page WebApps with Ember.jsManaging State in Single Page WebApps with Ember.js
Managing State in Single Page WebApps with Ember.jsMark Mansour
 
Intro to Ember.js
Intro to Ember.jsIntro to Ember.js
Intro to Ember.jsJay Phelps
 
jQuery in the [Aol.] Enterprise
jQuery in the [Aol.] EnterprisejQuery in the [Aol.] Enterprise
jQuery in the [Aol.] EnterpriseDave Artz
 
Avinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPressAvinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPresswpnepal
 
Pilot Tech Talk #9 — Ember.js: Productivity without the fatigue by Jacek Gala...
Pilot Tech Talk #9 — Ember.js: Productivity without the fatigue by Jacek Gala...Pilot Tech Talk #9 — Ember.js: Productivity without the fatigue by Jacek Gala...
Pilot Tech Talk #9 — Ember.js: Productivity without the fatigue by Jacek Gala...Pilot
 
Cheap frontend tricks
Cheap frontend tricksCheap frontend tricks
Cheap frontend tricksambiescent
 
Javascript Frameworks for Joomla
Javascript Frameworks for JoomlaJavascript Frameworks for Joomla
Javascript Frameworks for JoomlaLuke Summerfield
 
Getting classy with ES6
Getting classy with ES6Getting classy with ES6
Getting classy with ES6Andy Sharman
 
Angular js routing options
Angular js routing optionsAngular js routing options
Angular js routing optionsNir Kaufman
 
Simple Web Apps With Sinatra
Simple Web Apps With SinatraSimple Web Apps With Sinatra
Simple Web Apps With Sinatraa_l
 
Useful things to do with jQuery
Useful things to do with jQueryUseful things to do with jQuery
Useful things to do with jQueryJames Bubb
 
Jquery optimization-tips
Jquery optimization-tipsJquery optimization-tips
Jquery optimization-tipsanubavam-techkt
 
Amitesh Madhur - Web workers, HTML 5
Amitesh Madhur - Web workers, HTML 5Amitesh Madhur - Web workers, HTML 5
Amitesh Madhur - Web workers, HTML 5Amitesh Madhur
 

Tendances (20)

iPhone Appleless Apps
iPhone Appleless AppsiPhone Appleless Apps
iPhone Appleless Apps
 
Intro to Ember.JS 2016
Intro to Ember.JS 2016Intro to Ember.JS 2016
Intro to Ember.JS 2016
 
Ember.js for Big Profit
Ember.js for Big ProfitEmber.js for Big Profit
Ember.js for Big Profit
 
Webapps without the web
Webapps without the webWebapps without the web
Webapps without the web
 
Mojolicious, real-time web framework
Mojolicious, real-time web frameworkMojolicious, real-time web framework
Mojolicious, real-time web framework
 
Managing State in Single Page WebApps with Ember.js
Managing State in Single Page WebApps with Ember.jsManaging State in Single Page WebApps with Ember.js
Managing State in Single Page WebApps with Ember.js
 
Intro to Ember.js
Intro to Ember.jsIntro to Ember.js
Intro to Ember.js
 
jQuery in the [Aol.] Enterprise
jQuery in the [Aol.] EnterprisejQuery in the [Aol.] Enterprise
jQuery in the [Aol.] Enterprise
 
Avinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPressAvinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPress
 
Pilot Tech Talk #9 — Ember.js: Productivity without the fatigue by Jacek Gala...
Pilot Tech Talk #9 — Ember.js: Productivity without the fatigue by Jacek Gala...Pilot Tech Talk #9 — Ember.js: Productivity without the fatigue by Jacek Gala...
Pilot Tech Talk #9 — Ember.js: Productivity without the fatigue by Jacek Gala...
 
Cheap frontend tricks
Cheap frontend tricksCheap frontend tricks
Cheap frontend tricks
 
Javascript Frameworks for Joomla
Javascript Frameworks for JoomlaJavascript Frameworks for Joomla
Javascript Frameworks for Joomla
 
Getting classy with ES6
Getting classy with ES6Getting classy with ES6
Getting classy with ES6
 
Angular js routing options
Angular js routing optionsAngular js routing options
Angular js routing options
 
Built in filters
Built in filtersBuilt in filters
Built in filters
 
Simple Web Apps With Sinatra
Simple Web Apps With SinatraSimple Web Apps With Sinatra
Simple Web Apps With Sinatra
 
Useful things to do with jQuery
Useful things to do with jQueryUseful things to do with jQuery
Useful things to do with jQuery
 
Intro to jquery
Intro to jqueryIntro to jquery
Intro to jquery
 
Jquery optimization-tips
Jquery optimization-tipsJquery optimization-tips
Jquery optimization-tips
 
Amitesh Madhur - Web workers, HTML 5
Amitesh Madhur - Web workers, HTML 5Amitesh Madhur - Web workers, HTML 5
Amitesh Madhur - Web workers, HTML 5
 

Similaire à Java script+mvc+with+emberjs

[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVCAlive Kuo
 
Week 4 - jQuery + Ajax
Week 4 - jQuery + AjaxWeek 4 - jQuery + Ajax
Week 4 - jQuery + Ajaxbaygross
 
The Beauty Of Java Script V5a
The Beauty Of Java Script V5aThe Beauty Of Java Script V5a
The Beauty Of Java Script V5arajivmordani
 
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScriptjQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScriptGuy Royse
 
Ember.js for a CakePHP Developer
Ember.js for a CakePHP DeveloperEmber.js for a CakePHP Developer
Ember.js for a CakePHP Developerjtrapp07
 
Introduction to ECMAScript 2015
Introduction to ECMAScript 2015Introduction to ECMAScript 2015
Introduction to ECMAScript 2015Tomasz Dziuda
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on AndroidSven Haiges
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For BeginnersJonathan Wage
 
Sencha Touch - Introduction
Sencha Touch - IntroductionSencha Touch - Introduction
Sencha Touch - IntroductionABC-GROEP.BE
 
Writing Maintainable JavaScript
Writing Maintainable JavaScriptWriting Maintainable JavaScript
Writing Maintainable JavaScriptAndrew Dupont
 
AngularJS Directives
AngularJS DirectivesAngularJS Directives
AngularJS DirectivesEyal Vardi
 
The Open Web and what it means
The Open Web and what it meansThe Open Web and what it means
The Open Web and what it meansRobert Nyman
 
Building Large jQuery Applications
Building Large jQuery ApplicationsBuilding Large jQuery Applications
Building Large jQuery ApplicationsRebecca Murphey
 
jQuery Data Manipulate API - A source code dissecting journey
jQuery Data Manipulate API - A source code dissecting journeyjQuery Data Manipulate API - A source code dissecting journey
jQuery Data Manipulate API - A source code dissecting journeyHuiyi Yan
 
前端MVC 豆瓣说
前端MVC 豆瓣说前端MVC 豆瓣说
前端MVC 豆瓣说Ting Lv
 
JavaScript APIs - The Web is the Platform - MDN Hack Day - Buenos Aires
JavaScript APIs - The Web is the Platform - MDN Hack Day - Buenos AiresJavaScript APIs - The Web is the Platform - MDN Hack Day - Buenos Aires
JavaScript APIs - The Web is the Platform - MDN Hack Day - Buenos AiresRobert Nyman
 
Non Conventional Android Programming (English)
Non Conventional Android Programming (English)Non Conventional Android Programming (English)
Non Conventional Android Programming (English)Davide Cerbo
 
Non Conventional Android Programming En
Non Conventional Android Programming EnNon Conventional Android Programming En
Non Conventional Android Programming Enguest9bcef2f
 

Similaire à Java script+mvc+with+emberjs (20)

[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
 
The Beauty of Java Script
The Beauty of Java ScriptThe Beauty of Java Script
The Beauty of Java Script
 
Week 4 - jQuery + Ajax
Week 4 - jQuery + AjaxWeek 4 - jQuery + Ajax
Week 4 - jQuery + Ajax
 
The Beauty Of Java Script V5a
The Beauty Of Java Script V5aThe Beauty Of Java Script V5a
The Beauty Of Java Script V5a
 
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScriptjQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
 
Ember.js for a CakePHP Developer
Ember.js for a CakePHP DeveloperEmber.js for a CakePHP Developer
Ember.js for a CakePHP Developer
 
Introduction to ECMAScript 2015
Introduction to ECMAScript 2015Introduction to ECMAScript 2015
Introduction to ECMAScript 2015
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on Android
 
Clean Javascript
Clean JavascriptClean Javascript
Clean Javascript
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For Beginners
 
Sencha Touch - Introduction
Sencha Touch - IntroductionSencha Touch - Introduction
Sencha Touch - Introduction
 
Writing Maintainable JavaScript
Writing Maintainable JavaScriptWriting Maintainable JavaScript
Writing Maintainable JavaScript
 
AngularJS Directives
AngularJS DirectivesAngularJS Directives
AngularJS Directives
 
The Open Web and what it means
The Open Web and what it meansThe Open Web and what it means
The Open Web and what it means
 
Building Large jQuery Applications
Building Large jQuery ApplicationsBuilding Large jQuery Applications
Building Large jQuery Applications
 
jQuery Data Manipulate API - A source code dissecting journey
jQuery Data Manipulate API - A source code dissecting journeyjQuery Data Manipulate API - A source code dissecting journey
jQuery Data Manipulate API - A source code dissecting journey
 
前端MVC 豆瓣说
前端MVC 豆瓣说前端MVC 豆瓣说
前端MVC 豆瓣说
 
JavaScript APIs - The Web is the Platform - MDN Hack Day - Buenos Aires
JavaScript APIs - The Web is the Platform - MDN Hack Day - Buenos AiresJavaScript APIs - The Web is the Platform - MDN Hack Day - Buenos Aires
JavaScript APIs - The Web is the Platform - MDN Hack Day - Buenos Aires
 
Non Conventional Android Programming (English)
Non Conventional Android Programming (English)Non Conventional Android Programming (English)
Non Conventional Android Programming (English)
 
Non Conventional Android Programming En
Non Conventional Android Programming EnNon Conventional Android Programming En
Non Conventional Android Programming En
 

Dernier

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 

Dernier (20)

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 

Java script+mvc+with+emberjs

  • 1. JAVASCRIPT MVC WITH EMBER.JS @LASERJI 2012-06-12
  • 2. WHAT IS MVC ? Model + View + Controller
  • 3. MODEL var Person = { name: “”, say: function(thing){ alert(“fuck this “ + thing + “!”); } }; var person = new Person();
  • 4. VIEW We call {{somebody}} as BIG HOLE !!! {{#if person}} Welcome back <b>{{name}}</b> ! {{/if}}
  • 5. CONTROLLER (function($, exports){ var mod = {}; mod.doSomething = function(){ // do something }; mod.load = function(){ this.view = $(“#view”); }; })(jQuery, window);
  • 6. JAVASCRIPT MVC LIBRARIES • Backbone.js • Ember.js (SproutCore 2.0) • Spine.js • JavaScriptMVC • Sammy.js • YUILibrary • KnockoutJS • Angular.js • Fidel.js • ExtJS • http://www.infoq.com/cn/news/2012/05/js-mvc- framework
  • 7. EMBER.JS • Ember is a JavaScript framework for creating ambitious web applications that eliminates boilerplate and provides a standard application architecture. • Formerly known as AmberJS – formerly known as SprouteCore 2 • Emberjs.com • Ember.js VS. Backbone.js
  • 8. CREATING A NAMESPACE window.App = Ember.Application.create(); window.App = Ember.Application.create({ rootElement: '#sidebar' }); // namespace & event handler
  • 9. THE EMBER OBJECT MODEL Person = Ember.Object.extend({ say: function(thing) { alert(thing); } }); var person = Person.create(); person.say("Hello") // alerts "Hello"
  • 10. THE EMBER OBJECT MODEL // Passing in an object var tom = Person.create({ name: "Tom Dale", helloWorld: function() { this.say("Hi my name is " + this.get('name')); } }); tom.helloWorld() // alerts "Hi my name is Tom Dale"
  • 11. THE EMBER OBJECT MODEL // Reopening Classes and Instances Person.reopen({ isPerson: true }); Person.create().get('isPerson') // true Person.reopen({ // override `say` to add an ! at the end say: function(thing) { this._super(thing + "!"); } });
  • 12. COMPUTED PROPERTIES Person = Ember.Object.extend({ // these will be supplied by `create` firstName: null, lastName: null, fullName: function() { var firstName = this.get('firstName'); var lastName = this.get('lastName'); return firstName + ' ' + lastName; }.property('firstName', 'lastName') }); var tom = Person.create({ firstName: "Tom", lastName: "Dale" }); tom.get('fullName') // "Tom Dale"
  • 13. BINDINGS App.president = Em.Object.create({ name: "Obama” }); App.country = Em.Object.create({ presidentNameBinding: 'App.president.name' }); App.country.get('presidentName’); // “Obama"
  • 14. EVENT HANDELER App.ListingView = Ember.View.extend({ templateName: 'edit', edit: function(event) { alert('Edited') } });
  • 15. EVENT HANDELER App.ClickableView = Ember.View.extend({ click: function(evt) { alert("ClickableView was clicked!"); } });
  • 16. OTHER RESOURCES • http://www.adobe.com/devnet/html5/articles/flam e-on-a-beginners-guide-to-emberjs.html • http://emberjs.com/documentation/ • http://www.andymatthews.net/read/2012/03/07/G etting-Started-With-EmberJS • http://ngauthier.com/2012/02/playing-with- ember.html • http://emberjs.tumblr.com/