Here I have a just extracted my problematic part of code as it is an object with a clickInfo method that I want to use when testDivbtn in html is clicked
var product = {
jsondata:[
{title:"GearBox", price:80000},
{title:"Clutch", price:7000}
],
loadInfo:function (event) {
// This line is printing first product info from the jsondata array - just to test
console.log (this.jsondata[0].title + " " + this.jsondata[0].price);
}
}
This is simple div that is attached to click handler
$ ("#testDivbtn").click(product.loadInfo);
Here is html
<div class="col-sm6"><button id="#testDivbtn" type="button" class="btn btn-default">Test Product</button></div>
It is showing error in console - Cannot read property '0' of undefined I have this error at many other places in my app , If any one point the error it will be very helpful.