考虑这个标记
<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; …Run Code Online (Sandbox Code Playgroud) backbone.js ×1