Greetings fellow stackoverflowers,
I'm working on a jQuery class where I have a function that appends some html code to a container.
this.displayOptions = function(property, container) {
for (var i = 0; i < this[property + 'Count']; i++) {
$(container).append('<a href="#" onclick="' + call_a_function_from_this_class + '; return false"></a>');
}
}
So far, no problem. In this same class I have another function
this.setProperty = function(property, index) {
this[property] = index;
this.update();
}
I want the appended HTML to call this function setProperty
function when I click on it.
How can I do this?
For what's it worth, I initialize my class like this
var myVariable = new MyPlugin();
I know I could do <a href="#" onclick="myVariable.setProperty('', '')">
but the plugin can't know the variable.
Any help is appreciated!