Hi,

i was more or less trying to reproduce the json / tree example from the demo
site with very few little modifications and figured out that even on the
online example the "changeSelection" event is being fired three times when i
click a node on the tree.

Is this a Bug or is this on purpose and if so, what's the purpose?
I want to attach some functions to the changeSelection even of the tree but
I don't want those functions to be called three times. 

I would like to keep my prototypes as simple as possible.
After I realized the json/tree controller solution fires several times i
filled a tree manually with treefolder objects and checked if the resulting
tree also fires its changeSelection events three times - but it was good and
fired only *one* event.

Now what would I have to do? Do my own Model/Delegate solution? I already
started that, but for the moment the code below would do it to me as long at
it wouldn't fire events too many times.


My current code:

/**
 * @author phill54
 */

qx.Class.define("jsonTreeTest.TreeModelTest",
{
        extend : qx.core.Object,
        construct : function () {
                var tree = new qx.ui.tree.Tree().set({
                        selectionMode : "one",
                        hideRoot : false,
                        rootOpenClose : true,
                        width: 400,
                        height: 300
                });
                
                var controller = new qx.data.controller.Tree(null, tree, 
"kids", "name");
                controller.setIconPath("iconpath");
                
                var url = "http://phill54/datasource/tree.json.php";;
                var store = new qx.data.store.Json(url);
                store.bind("model", controller, "model");
                controller.bind("model", store, "model");
                
                tree.addListener("changeSelection", function(ev) {
                        /* this function is executed three times on click on a 
node*/
                        var data = ev.getData();
                        
                        console.log("typeof:\t\t\t" + typeof(data[0]));
                        console.log("length:\t\t\t" + data[0].length);
                        
                        /* this function shows me the label/name of the 
selected node
                        it turns out that the changeSelection gets fired 3 
times:
                        1st time: event data gives me the previously selected 
tree node
                        2nd time: event data gives me the currently selected 
tree node
                        3rd time: event data gives me the currently selected 
tree node again
(!!!)
                        */
                        console.log(data[0].getModel().getName());
                }, this);
                
                store.addListener("loaded", function(ev) {
                        tree.getRoot().setOpen(true);
                }, this);
                
                qx.core.Init.getApplication().getRoot().add(tree, {top: 10, 
left: 10});
        },
        destruct : function () {
        },
        properties : {
        },
        members : {
        }
});

-- 
View this message in context: 
http://n2.nabble.com/Json-Store-Tree-Controller-changeSelection-event-gets-fired-three-times-per-click-tp4107042p4107042.html
Sent from the qooxdoo mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing. 
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to