Code flow doesn't reach the render function
ly In the following code, the render function is called in the loop below.
The wierd thing is that the line of code before the function
call(console.log) works but the console.log directy inside the function
doesn't work. check out the for(var i in coupons) line Moreover, the line
after the function call doesn't work.console,log(e). Also d is only
executed once instead of 3 times as the length of the array is 3 I am
unable to use the popup's console because it crashes my system(yes it
actually does). So I am having to rely on this.
function render(template,object){
chrome.extension.getBackgroundPage().console.log("Hello")//This doesn't
var placeholders=/\$\{([A-Za-a0-9_]+)\}/.exec(template);
chrome.extension.getBackgroundPage().console.log(placeholders);//Neither
does this
}
function update(){
chrome.extension.sendRequest({'action' : 'fetchCoupons'},
function(couponsObj) {
//
chrome.extension.getBackgroundPage().console.log('coupons');
//chrome.extension.getBackgroundPage().console.log($.tmpl);
var template=$("#coupons-template").html()
//$(".coupons").html(template )
//$couponscontent=$.tmpl(template,coupons)
var coupons=couponsObj.coupons;
var deals=couponsObj.deals;
chrome.extension.getBackgroundPage().console.log(coupons);
for(i in coupons){
chrome.extension.getBackgroundPage().console.log("d");//This
console.log works
render(template,coupouns[i]);//This line calls the
render function
chrome.extension.getBackgroundPage().console.log("e");
}
}
);
}
update();
No comments:
Post a Comment