Hi all,

something puzzled me with qx 0.6.2 and I couldn't find anything related in
bugzilla: 

A function creates a button and adds an event listener (in this "anonymous
inner method"-way, or whatever you'd call that in JavaScript). Now the event
handler modifies a variable 'tableModel' defined in the same function.

In the source tree everything works fine no matter if I declare 'tableModel'
before or after adding the listener (why that should work at all, I don't
know, since I don't come to terms with variable-scope in JavaScript :). The
build version, however, only works if I declare 'tableModel' *before* adding
the listener to the button.

Here's the code:

qx.OO.defineClass("bug1.Application", qx.component.AbstractApplication,
function () {
  qx.component.AbstractApplication.call(this);
});

createTestPanel = function() {

    // create a button with an event listener modifying a table model

    var submit = new qx.ui.form.Button("Submit");
    submit.addEventListener("execute", function(e) {
        tableModel.setData([[1,"Company 1","City 1","Street 1"],
                            [2,"Company 2","City 2","Street 2"]]);
    }, this);

    // Define the table model and a table on top of it.

    // FIX the problem by moving the next line of code
    // before the definition of the button listener

    var tableModel = new qx.ui.table.SimpleTableModel();
    tableModel.setColumns(["Id","Name","City","Street"]);
    var table = new qx.ui.table.Table(tableModel);
    with (table) {
        setWidth("100%");
        setHeight(qx.constant.Core.FLEX);
        setBorder(qx.renderer.border.BorderPresets.getInstance().thinInset);
    };

    // layout the widgets

    var panel = new qx.ui.layout.VerticalBoxLayout();
    with(panel) {
        set({ left:10, top:10, right:10, bottom:10 });
        setSpacing(10);
        add(submit);
        add(table);
    }

    return(panel);
}

qx.Proto.main = function(e) {
    var d = qx.ui.core.ClientDocument.getInstance();

    var panel = createTestPanel();

    d.add(panel);
};

Regards,
Martin




-------------------------------------------------------------------------
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

Reply via email to