javascript - Passing data into the render Backbone.js -


is possible pass questions variable view render?

ive attempted calling this.render inside success on fetch got error, presumably it's because this. not @ correct scope.

app.appview = backbone.view.extend({     initialize: function(){           var inputs = new app.form();          inputs.fetch({              success: function() {                  var questions = inputs.get(0).tojson().questions;                  app.validate = new validate(questions);                 app.validate.questions();                }, // end success()              error: function(err){                 console.log("couldn't service " + err);             }          }); // end input.fetch()          this.render();      }, // end initialize      render: function(){         el: $('#finder')         var template = _.template( $("#form_template").html(), {} );         this.$el.html(template);      }  

the success callback called different this object view instance. easiest way fix add before call inputs.fetch:

var self = this; 

and inside success callback:

self.render(); 

Comments

Popular posts from this blog

ruby on rails - Permission denied @ sys_fail2 - (D:/RoR/projects/grp/public/uploads/ -

c++ - nodejs socket.io closes connection before upgrading to websocket -

python - PyQt: Label not showing correct number of length -