javascript - Accessing method variables in Backbone views (parse views) -



javascript - Accessing method variables in Backbone views (parse views) -

how can access object "context" in parse.find function globally? getting error "uncaught reference error: context not defined". new backbone.js. have seen couple of posts regarding scoping of backbone views. didn't help me. help appreciated.

var messageview = parse.view.extend({ el: "#post", context:"", tagname: "li", initialize: function() { var self = this; this.render(); console.log('message view initialized'); }, render: function(res) { //var context; // declaring here global variable doesn't help var query = new parse.query(message); query.find({ success:function(results){ for(var i=0;i<results.length;i++){ results[i].from=results[i].attributes.from; results[i].message=results[i].attributes.messagebody; message.set("from",results[i].from); message.set("message",results[i].message); } context={from:message.attributes.from,message:message.attributes.message}; //i want object accessed anywhere in render function }, error:function(error){ console.log(error); } }); var source=$("#messagetmpl").html(); var messagetemplate = handlebars.compile(source); // need access context object in parse.find({}) here // context variable values "from" , "messagebody" var html = messagetemplate(context); console.log(context); this.$el.html(html); }, });

i found question similar mine. [question]backbone view access methods variables

declare view property?

var messageview = parse.view.extend({

el: "#post", context:"", tagname: "li", query: new parse.query(message), initialize: function() { ... }, render: function(res) { ...

javascript backbone.js parse.com

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -