I have a JavaScript class like this
function Palette() {
this.selectedItem = "";
this.addBox = function() {
// Different approach, create a fake box
b = $("<div id='box-palette' class='box'>Box</div>");
b.insertBefore('#cont');
b.mousedown(function() {
this.selectedItem = "box"; // Here I want to access Palette#selectedItem
console.log(Palette);
});
}
}
How can I access the property of the class in the function I want to pass to jQuery?
Any help will be appreciated. Thanks!