Tag: backbone events

将事件绑定到下划线/主干中的动态对象

我正在试图弄清楚如何在没有原型的对象上监听自定义事件,或者在underscore.js / backbone.js中不是dom对象。 例如: //this is inside a view object play: function(arg) { this.a = this.image(this.model.a); this.a.bind(“ready”,start,this);//<— causes error this.b = this.image(this.model.b); this.b.bind("ready",start,this);//<— causes error function start() { // do some stuff in here } //some more stuff }, image: function(args) { // load the image, get its data, attach to original model then return […]

在骨干视图中访问el之外的click事件

如何访问el范围之外的click事件。 我有什么:HTML: 查看: var ForgotPasswordView = Backbone.View.extend({ el: “#template_loader”, initialize: function () { console.log(‘Forgot Password View Initialized’); }, render: function () { blockPage(); var that = this; $.get(App.baseUrl + ‘templates/forgot-password-view.html’, function (data) { template = _.template(data, { }); that.$el.html(template); unblockPage(); }, ‘html’); }, events:{ ‘click .right_btn’:’forgotPasswordSubmit’, //Doesn’t fire as its outside of el }, forgotPasswordSubmit: […]