与Backbone.Router的Ploblem。
我有导航
我的代码:
<div id="menu">
<ul>
<li><a href="#!/">Start</a></li>
<li><a href="#!/success">Success</a></li>
<li><a href="#!/error">Error</a></li>
</ul>
</div>
<script>
$(function () {
var Control = Backbone.Router.extend({
routes: {
"": "start",
"!/": "start",
"!/success": "success",
"!/error": "error"
},
start: function () {
console.log('start')
},
success: function () {
console.log('success');
},
error: function () {
console.log('error')
// $(".block").hide();
// $("#error").show();
}
});
var controllers = new Control();
Backbone.history.start();
});
错误:
TypeError:Backbone。$(...)。on不是函数
Backbone。$(window).on('hashchange',this.checkUrl);