码迷,mamicode.com
首页 > 其他好文 > 详细

-_-#【Backbone】View

时间:2014-12-18 16:27:27      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:style   blog   ar   io   color   os   sp   for   on   

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" href="../../app-min.css">
    <script src="../../jquery/jquery-1.10.2.js"></script>
    <script src="../underscore.js"></script>
    <script src="../backbone.js"></script>
    <script>
        var SearchView = Backbone.View.extend({
            initialize: function() {
                console.log(init a SearchView)
            },
            render: function(context) {
                var template = _.template($(#search_template).html(), context)
                $(this.el).html(template)
            },
            events: {
                click input[type=button]: doSearch
            },
            doSearch: function(event) {
                console.log(search for  + $(#search_input).val())
            }
        })
        var searchView = new SearchView({el: $(#search_container)})
        searchView.render({search_label: 搜索渲染})
    </script>
    <article class="content">
        <pre>var SearchView = Backbone.View.extend({
    initialize: function() {
        console.log(‘init a SearchView‘)
    },
    render: function(context) {
        var template = _.template($(‘#search_template‘).html(), context)
        $(this.el).html(template)
    },
    events: {
        ‘click input[type=button]‘: ‘doSearch‘
    },
    doSearch: function(event) {
        console.log(‘search for ‘ + $(‘#search_input‘).val())
    }
})
var searchView = new SearchView({el: $(‘#search_container‘)})
searchView.render({search_label: ‘搜索渲染‘})</pre>
    </article>
</body>
</html>

 

-_-#【Backbone】View

标签:style   blog   ar   io   color   os   sp   for   on   

原文地址:http://www.cnblogs.com/jzm17173/p/4171836.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!