Here's my situation. I have an object
function Obj () {
this.foo = null;
}
a function
function bar() {...}
another function
function doSomething () {
var obj = new Obj();
obj.foo = bar;
doSomethingElse (obj);
}
In function doSomethingElse I want to create the following line of DHTML
<div onClick="obj.fo o(); return true;">
What I want is for onClick to be defined to be the execution of the foo
method of obj.
I tried document.writel n ("<div onClick='" + obj.foo + "(); return
true;'>");
What I get is the source code for bar stuck into the middle of the string.
So how do I get just the name of the function bar in the string? Or
ultimately, how do I get the handler to be bar in the DHTML?
Thanks.
Ken
function Obj () {
this.foo = null;
}
a function
function bar() {...}
another function
function doSomething () {
var obj = new Obj();
obj.foo = bar;
doSomethingElse (obj);
}
In function doSomethingElse I want to create the following line of DHTML
<div onClick="obj.fo o(); return true;">
What I want is for onClick to be defined to be the execution of the foo
method of obj.
I tried document.writel n ("<div onClick='" + obj.foo + "(); return
true;'>");
What I get is the source code for bar stuck into the middle of the string.
So how do I get just the name of the function bar in the string? Or
ultimately, how do I get the handler to be bar in the DHTML?
Thanks.
Ken
Comment