考虑这个标记
<div id="controls" class="controls">
<a href="#">Home</a> -
<a href="#/get">get</a> -
<a href="#/new">new</a>
<input type="text" val="" id="input">
</div>
Run Code Online (Sandbox Code Playgroud)
而这段javascript:
$(document).ready(function() {
"use strict";
// this is used on my code as root.App,
// but the code was omitted here for clarity purposes
var root = this,
undefined;
var controller = Backbone.Controller.extend({
routes : {
// static
},
});
var view = new Backbone.View.extend({
el : $('#controls'),
events : {
'click a' : 'updateOnEnter'
},
updateOnEnter : function(el) {
alert('sss');
return this;
},
initialize : function() {
_.bindAll(this, 'render', 'updateOnEnter');
},
render : function() {
return this;
}
});
new view;
new controller;
Backbone.history.start();
)};
Run Code Online (Sandbox Code Playgroud)
当view调用(with new view)时,Firebug会触发此错误:
parent.apply is not a function
error backbone.js (line 1043): child = function(){ return parent.apply(this, arguments); };
Run Code Online (Sandbox Code Playgroud)
为什么会发生这种情况的任何想法?谢谢.
eag*_*eal 88
没关系.
问题出在上面js代码的第16行:
var view = new Backbone.View.extend({
Run Code Online (Sandbox Code Playgroud)
它应该是:
var view = Backbone.View.extend({
Run Code Online (Sandbox Code Playgroud)
我没有删除这个问题,因为有人可能觉得它很有用.我想,不是来自CS背景的陷阱.
| 归档时间: |
|
| 查看次数: |
8161 次 |
| 最近记录: |