On 02/11/2010 02:27 PM, Marcel Ruff wrote:
> Hi,
>
> I have a qooxdoo class, where I create a plain HTML table:
>
> {
> // inside my qooxdoo class ...
> var tableData = ...
> tableData += "<td><a href='#' onclick='doSomething(); return
> false;'>bla</a>" + ...
> // other framework displays the table
> }
>
> When the user clicks on the 'bla' link the global function doSomething()
> is triggered.
>
> But I have lost the qooxdoo 'this' context, how can I pass 'this'?
Well, for one thing, I don't see you using "this" in any of the code you
provided, so it is hard to make recommendations.
Secondly, as you say you are using a global function, doSomething().
This one doesn't require a 'this', or does it?!
If you find the doSomething() function should work on the qooxdoo class
that produces the HTML table, you have to find a way to pass a reference
to this instance to the global function.
Instead of a global function you could have a static class that provides
the function as a method, like "my.Static.doSomething()". This class
could have another method my.Static.setContext(), which you call in your
other class before generating the HTML table, passing "this" as an
argument, which is then stored inside the static class.
my.Static.doSomething() could then access this field, to obtain a
reference to the HTML producing class.
But let me also say this is pretty much bad practice, as you are
imposing a protocol this way, and not very much 00 :).
T.
------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel