Jon,
I think it might have to do with scope.
In Javascript to declare
var w2 = new QxCanvasLayout();
means that w2 is a local variable
( I believe - however don't ask me: local to what? in the context of
server-sent JS executed inside the "completed" event...
I come from a Delphi background and JS plus Qooxdoo is still a lot like
Myth and Magic to me :)
).
However when I encountered a similiar problem what I found to work for
me was to declare a widget like this
w2 = new QxCanvasLayout();
This seems to make w2 global and I succesfully can apply server-sent JS
code to manipulate w2 (and also dispose of it).
HTH - give it a try
Cheers - Ralf
Jon Fawcett wrote:
> I have some dynamically added widgets that are generated from php code
> that returns javascript via QxRequest. The new widgets get displayed
> fine, but when trying to remove them later, I receive a "[widgetname]"
> is not defined error in my debugger window. Any pointers to what I'm
> doing wrong?
>
> Thanks,
> Jon
>
> Here's some very simple sample code that produces the problem I'm
> experiencing. :
>
> ------------------------------------------------------------
> index.html
> ------------------------------------------------------------
> <?xml version="1.0" encoding="iso-8859-1"?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
> "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml"" xml:lang="de">
> <head>
> <meta http-equiv="Content-Type" content="text/html;
> charset=iso-8859-15" />
> <title>Test</title>
> <script type="text/javascript"
> src="./qooxdoo/script/qooxdoo.js"></script>
> </head>
> <body>
> <script type="text/javascript">
> window.application.main = function()
> {
> var main = this.getClientWindow().getClientDocument();
>
> var w1 = new QxCanvasLayout();
> w1.setBackgroundColor(new QxColorObject("threedface"));
> w1.setWidth(300);
> w1.setHeight(150);
> w1.setBottom(20);
> w1.setRight(20);
> w1.setPadding(10);
> w1.setOpacity(1);
> w1.setBorder(QxBorderObject.presets.inset);
> main.add(w1);
>
> var b = new QxButton("open");
> b.setTop(0);
> b.setLeft(0);
> b.setWidth(100);
> b.addEventListener("click", functionOpen);
> w1.add(b);
>
> var b2 = new QxButton("close");
> b2.setBottom(0);
> b2.setRight(0);
> b2.setWidth(100);
> b2.addEventListener("click", functionClose);
> w1.add(b2);
>
> function functionOpen(e){
> var req = new QxRequest("open.html", "GET", "text/plain");
> req.addEventListener("completed", function(e) {
> eval(e.getData().getContent());
> });
> req.send();
> };
>
> function functionClose(e){
> var req = new QxRequest("close.html", "GET", "text/plain");
> req.addEventListener("completed", function(e) {
> eval(e.getData().getContent());
> });
> req.send();
> };
> }
> </script>
> </body>
> </html>
>
> -------------------------------------------------------------------
> Close.html
> -------------------------------------------------------------------
> var w2 = new QxCanvasLayout();
> w2.setBackgroundColor(new QxColorObject("threedface"));
> w2.setWidth(300);
> w2.setHeight(150);
> w2.setTop(20);
> w2.setLeft(20);
> w2.setPadding(10);
> w2.setOpacity(1);
> w2.setBorder(QxBorderObject.presets.inset);
> main.add(w2);
>
> -------------------------------------------------------------------
> Open.html
> -------------------------------------------------------------------
> main.remove(w2);
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys -- and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel