Note that there are some explanatory texts on larger screens.

plurals
  1. PObackbone view events not firing after rendering
    text
    copied!<p>I have a backbone view like this</p> <pre><code>define(['backbone','text!templates/settings.html'], function( Backbone, SettingsTemplate) { var SettingsView = Backbone.View.extend({ el:"#settings-screen", viewTemplate: _.template(SettingsTemplate), events: { "click button#save-settings":"save" }, initialize: function() { }, render: function() { $("#game-viewport").html(this.viewTemplate); }, save: function(event) { console.log(event); } }); return SettingsView; </code></pre> <p>});</p> <p>This is view is initialized via my router</p> <pre><code>define(['backbone','views/settings'], function(Backbone,SettingsView) { var Router = Backbone.Router.extend({ routes: { "newgame":"showGameview", "settings":"showSettingsview" }, switchView: function(view) { if(this.currentView) this.currentView.close() this.currentView = view; this.currentView.render(); }, showGameview: function() { }, showSettingsview: function() { var view = new SettingsView; this.switchView(view); } }); return Router; }); </code></pre> <p>And this starts up the app</p> <pre><code>require.config({ paths: { 'backbone':'./libs/backbone', 'underscore':'./libs/underscore-min', 'text':'./plugins/text', 'domReady':'./plugins/domReady' }, shim:{ 'backbone': { deps: ['underscore'], exports: 'Backbone' } } }); require(['domReady','views/start','routers/router'], function(domReady, StartView, Router) { domReady(function() { var view = new StartView; view.render(); var router = new Router(); Backbone.history.start(); }); }); </code></pre> <p>But after the view has being rendered, the events dont fire. What could be wrong?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload