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

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -