I got it working by adding a new parameter to linkbuttonajax(). So now it's like onclick="linkbuttonajax('http://example.com',1,true,this.childNodes[1].childNodes[0]);return false;"
Why does "this" work in the onclick, but not in the function?
Why does "this" work in the onclick, but not in the function?
That's impossible to say without looking at the function. You usually get this issue with events and Internet Explorer as it wrongly binds this to window. There are work arounds for that though.
In your case however I'm guessing it's related to Ajax, which unfortunately I'm not that clued up on.
That said if you are at liberty to post the code for linkbuttonajax, I'm sure someone else here could shed some light on it.
Good you've got it working though.
I got it working by adding a new parameter to linkbuttonajax(). So now it's like onclick="linkbuttonajax('http://example.com',1,true,this.childNodes[1].childNodes[0]);return false;"
That extra parameter sets the context I'm guessing.
Somewhere in there I'm guessing it's using a call or apply, which that parameter is passed into.
Simple example.
Code:
var obj = {name:'Fred'};
function sayName(message){ alert (message + this.name) }
// call sayName in the context of obj
sayName.call(obj, 'Hello '); // Hello Fred
Bookmarks