Hi.
I'm having troubles to come up with a way to assign an object's method to a DOM-node created by the object without hardcoding object's name.
For example:
This code works, but in that way I'm binded to a specific hardcoded variable name and able to create only one working object of that class per page, which is not good at all.
How can it be done in another way?
Thanx.
I'm having troubles to come up with a way to assign an object's method to a DOM-node created by the object without hardcoding object's name.
For example:
Code:
function currancySwitcher(){
this.currancy = ['euro','usd','sek']
var a = document.createElement('a');
a.title = this.currancy[0]
a.href = '#'+this.currancy[0]
a.onclick = function(){
myObject.setCurrancy(this.title);
return false;
}
this.setCurrancy = function(currancy){
}
}
var myObject = new currancySwitcher();
How can it be done in another way?
Thanx.
Comment