zoukankan      html  css  js  c++  java
  • What is a view?

     1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
     3 <head>
     4     <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
     5     <title></title>
     6     <script type="text/javascript" src="jquery-1.8.0.min.js"></script>
     7     <script type="text/javascript" src="underscore.js"></script>
     8     <script type="text/javascript" src="backbone.js"></script>
     9     <script type="text/javascript" src="index.js"></script>
    10 </head>
    11 <body>
    12     <div id="search_container">a</div>
    13     <script type="text/template" id="search_template">
    14     <label>Search</label>
    15     <input type="text" id="search_input" />
    16     <input type="button" id="search_button" value="Search" />
    17     </script>
    18 </body>
    19 </html>
     1 $(window).load(function() {
     2     SearchView = Backbone.View.extend({
     3         initialize: function() {
     4             this.render();
     5         },
     6         render: function() {
     7             // Compile the template using underscore
     8             var template = _.template($("#search_template").html(), {});
     9             // Load the compiled HTML into the Backbone "el"
    10             this.el.html(template);
    11         },
    12         events: {
    13             "click input[type=button]": "doSearch"
    14         },
    15         doSearch: function(event) {
    16             // Button clicked, you can access the element that was clicked with event.currentTarget
    17             alert("Search for " + $("#search_input").val());
    18         }
    19     });
    20 
    21     var search_view = new SearchView({
    22         el: $("#search_container")
    23     });
    24 });
  • 相关阅读:
    Github账户注册的过程
    目前流行的源程序版本管理软件和项目管理软件都有哪些, 各有什么优缺点?
    作业二:四则运算
    学习进度
    对构建之法的一些问题
    个人介绍
    对《软件工程》课程的总结
    作业八 更新版
    作业八
    冲刺总结博客
  • 原文地址:https://www.cnblogs.com/qzsonline/p/2642737.html
Copyright © 2011-2022 走看看