Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Javascript MVC

Bhavesh Furia
December 26, 2012

Javascript MVC

My first tech-talk at 8Rays Technosoft due to which I researched about JS-MVC and presented what I learned through it.

Bhavesh Furia

December 26, 2012
Tweet

Other Decks in Programming

Transcript

  1. Backbone Model var PersonModel = Backbone.Model.extend({ initialize:function(){ }, defaults:{ “name”:”PersonName”

    } }); var p = new PersonModel(); /*initialize()*/ p.set(“name”,”Bhavesh”); /*setter method*/ alert(p.get(“name”)); /*getter method*/ p.toJSON();
  2. Backbone Collections var PersonsCollection = Backbone.Collection.extend({ model:Person }); var pc

    = new PersonsCollection(); push, pop, shift, length, sort, where, fetch
  3. Backbone Router var myRouter = Backbone.Router.extend({ routes:{ “” : “home”,

    “search/:query” : ”search”, “search/:query/p:personId” : ”search” }, home:function(){ … }, search:function(query,personId){ … } });
  4. Backbone View var sidebarItems = Backbone.View.extend({ tagName: “li”, className:”item”, events:function(){

    “click .icon” : “open”, “click .button.edit” : “openEditDialog” “click .button.delete” : “destroy” }, render:function(){ $(this.el).html(“Hello World!s”); return this; } });