can't get ontap function to work when created via createComponent

edited March 2012 in General
I'm trying to figure out why I can't get an ontap handler to work when it's created dynamically in a loop in my create: function() and then inside of a createComponent function. SEE BELOW THE LAST createComponent with the "ontap". If I do this same construction statically, ontap works no problem, but here in this dynamic construction, it does not register even though it does appear as an object property. It will not fire however. Any help would be appreciated, thanks!
    kind: enyo.Control,
    name: "nav",
    tag: "ul",
        {tag: "li",content: ".", classes: "nav_top_spacer"},
    create: function(){
        var menu_overall_width = 14;
        for(var i in NAV_TOP){

           { tag: "li",  style: style_exception,  classes: "nav_top nav_home", components: [
                {tag: "span", classes: "nav_top",  content: NAV_TOP[i]['dept_nav_name']},
                {tag: "ul", name: NAV_TOP[i]['dept_id'], classes: "nav_clear nav_dropdown",                                                     components:[                                                                          

        //dropdown menu items
        var x = 0;
        for(var i in NAV_SUB){
            var dept_id = NAV_SUB[i][0]['dept_id'];
                for(var x in NAV_SUB[i]){
                   var nav_name = NAV_SUB[i][x].nav_name;
                   var nav_id = "home_nav_" + dept_id;

                        {tag: "li", classes: "nav_dropdown", name: nav_name , content: nav_name, ontap: "dothis"}

    dothis: function(inSource, inEvent){


  • edited March 2012
    this.$[dept_id].createComponent creates a component owned by this.$[dept_id]. Events always go to the owner. I think to make it a child of that node but still owned by 'this' you'd want to do something like:
    this.createComponent({tag: "li", classes: "nav_dropdown", name: nav_name, 
        content: nav_name, ontap: "dothis"}, {parent: this.$[dept_id]});
    this.$[dept_id].createComponent({tag: "li", classes: "nav_dropdown",
        name: nav_name , content: nav_name, ontap: "dothis"}, {owner: this});
Sign In or Register to comment.