Backbone.js Introductory Tutorial Second Edition notes (1)

Source: Internet
Author: User

<! DOCTYPE html>    (function ($) {        varWorld=Backbone.Model.extend ({name:NULL //Why create an empty name        }); varworlds=Backbone.Collection.extend ({initialize:function(models,options) { This. On ("Add", Options.view.addOneWorld);//Initialize binding Add method            }        }); varappview=Backbone.View.extend ({el:$ (' Body '),//specifies the associated elementInitializefunction(){//Initialize Method                 This. worlds=NewWorlds (NULL, {view: This})//instantiate a collection and create a property view to hold the view}, events:{' Click #check ': "CheckIn"//Binding the #check click event}, CheckIn:function(){                varWorld_name=prompt ("Excuse me, which star are you?")); World_name|| (World_name = ' unknown '); varWorld=NewWorld ({name:world_name});//instantiate a module and set the value of name                 This. Worlds.add (World);//to add a module to a collection}, Addoneworld:function(model) {$ ("#world-list"). Append ("<li> here is from <b>" + model.get (' name ') + "</b> Planet greeting </li>");        }        }); varAppview =NewAppview;//Instantiate Appview}) (JQuery); </script></body>

Backbone.js Introductory Tutorial Second Edition notes (1)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.