2 wuyixiang9 wuyixiang9 于 2014.08.19 14:10 提问

backbone view 绑定视图事件报没有off方法
<!DOCTYPE html>
<html>
<head>
    <script src="jquery.js"></script>
    <script src="underscore.js"></script>
    <script src="backbone.js"></script>
</head>
<body>
    <div id="search_container"></div>
    <script type="text/javascript">
        SearchView = Backbone.View.extend({
            events: {
                "click": "open"
            },
            open: function( event ){
                alert();
            }
        });
        var search_view = new SearchView({ el: $("#search_container") });
    </script>
</body>
</html>

Uncaught TypeError: Object [object Object] has no method 'off' backbone.js:1143
_.extend.undelegateEvents backbone.js:1143
_.extend.delegateEvents backbone.js:1121
_.extend.setElement backbone.js:1092
_.extend._ensureElement backbone.js:1171
Backbone.View backbone.js:1039
child backbone.js:1661
(anonymous function)

1个回答

jasondu264
jasondu264   2014.11.27 10:12

var search_view = new SearchView({ el: "#search_container") });
el不应该传jquery对象

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!