Sigma Php Ajax framework, Ajax Components, GUI Builder
May 23, 2012, 08:39:26 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Accesing parent from the Dialog beforeClose event  (Read 308 times)
vilgilsoft
Newbie
*
Posts: 1


View Profile
« on: January 11, 2012, 02:32:17 AM »

Hi
 I have created a dialog in a button press event. I have set the event. The beforeClose event of the dialog box gets activated correctly. I tested it by putting a alert box. It works..

My problem is how to access the other controls from the dialog beforeClose Event.

I have the Canvas in which there is a menu bar. When the menu is clicked, the menu is hidden and the dialog is shown. When the dialog is closed the menu bar should be made visible. to access the menubar i need to access the parent / host -  right ? So how to access it ?




// The default code is a com class (inherited from linb.Com)
Class('App', 'linb.Com',{
    // Ensure that all the value of "key/value pair" does not refer to external variables
    Instance:{
        // To initialize instance(e.g. properties)
        initialize : function(){
            // To determine whether or not the com will be destroyed, when the first UI control be destroyed
            this.autoDestroy = true;
            // To initialize properties
            this.properties = {};
            window.mainlinb = this;
        },
        // To initialize internal components (mostly UI controls)
        // *** If you're not a skilled, dont modify this function manually ***
        iniComponents : function(){
            // [[code created by jsLinb UI Builder
            var host=this, children=[], append=function(child){children.push(child.get(0))};
           
            append(
                (new linb.UI.SLabel)
                .setHost(host,"ctl_slabel9")
                .setDock("top")
                .setCaption("VIL 4 CA")
                .setCustomStyle({"KEY":"font-family:georgia,serif;font-size:34pt;font-weight:normal;font-style:italic;text-align:left"})
            );
           
            append(
                (new linb.UI.MenuBar)
                .setHost(host,"mnuBar")
                .setItems([{"id":"mnuClient", "sub":[{"id":"mnuClientManager", "caption":"Client Manager"}, {"id":"disabled", "caption":"disabled", "disabled":true}, {"id":"image", "caption":"image", "image":"img/demo.gif"}, {"type":"split"}, {"id":"checkbox 1", "caption":"checkbox 1", "type":"checkbox"}, {"id":"checkbox 2", "caption":"checkbox 2", "type":"checkbox"}], "caption":"Client"}, {"id":"menu2", "sub":[{"id":"sub menu 1", "caption":"sub menu 1", "add":"[Ctrl+F]", "sub":[{"id":"sub 1", "type":"radiobox"}, {"id":"sub 2", "type":"radiobox"}, {"id":"sub 3"}]}, {"id":"sub menu 2", "caption":"sub menu 2", "add":"[Ctrl+T]", "sub":["sub 3", "sub 4"]}], "caption":"menu2"}])
                .onMenuSelected("mnuBar_onmenuselected")
            );
           
           
            return children;
            // ]]code created by jsLinb UI Builder
        },
        // Give a chance to load other com
        iniExComs : function(com, threadid){
        },
        // Give a chance to determine which UI controls will be appended to parent container
        customAppend : function(parent, subId, left, top){
            // "return false" will cause all the internal UI controls will be added to the parent panel
            return false;
        },
        // This instance's events
        events : {},
        _ctl_sbutton1_onclick : function (profile, e, src, value) {
            var uictrl = profile.boxing();
            linb.alert("hi","I'm " + uictrl.getAlias());
        },
        mnuBar_onmenuselected : function (profile, popProfile, item, src) {
           
            var ns = this, uictrl = profile.boxing();
            var caption = '';
            var modulefile = '';
           
           
           
            switch (item.id)
            {
                case 'mnuClientManager':
                   caption = 'Client Manager';
                   modulefile = 'clientmanager.html';
                   break;
            }
           
            ns.mnuBar.setVisibility("hidden",true);
            var dlg = new linb.UI.Dialog({caption:caption,status:"max",iframeAutoLoad:modulefile});
            dlg.beforeClose(ns.ChildWindow_Closed);
            dlg.showModal();

        },
       
       
        ChildWindow_Closed : function(profile)
        {
          //I dont want to use window.mainling.mnuBar here. How else can i access it ?
            window.mainlinb.mnuBar.setVisibility("visible",true);
        }
       
       
    }
});


Thanks
Logged
linb
Administrator
Hero Member
*****
Posts: 435


View Profile
« Reply #1 on: January 11, 2012, 04:46:27 PM »

Class('App', 'linb.Com',{
    Instance:{
        iniComponents : function(){
            // [[code created by jsLinb UI Builder
            var host=this, children=[], append=function(child){children.push(child.get(0))};
           
            append(
                (new linb.UI.SLabel)
                .setHost(host,"ctl_slabel9")
                .setDock("top")
                .setCaption("VIL 4 CA")
                .setCustomStyle({"KEY":"font-family:georgia,serif;font-size:34pt;font-weight:normal;font-style:italic;text-align:left"})
            );
           
            append(
                (new linb.UI.MenuBar)
                .setHost(host,"mnuBar")
                .setItems([{"id":"mnuClient", "sub":[{"id":"mnuClientManager", "caption":"Client Manager"}, {"id":"disabled", "caption":"disabled", "disabled":true}, {"id":"image", "caption":"image", "image":"img/demo.gif"}, {"type":"split"}, {"id":"checkbox 1", "caption":"checkbox 1", "type":"checkbox"}, {"id":"checkbox 2", "caption":"checkbox 2", "type":"checkbox"}], "caption":"Client"}, {"id":"menu2", "sub":[{"id":"sub menu 1", "caption":"sub menu 1", "add":"[Ctrl+F]", "sub":[{"id":"sub 1", "type":"radiobox"}, {"id":"sub 2", "type":"radiobox"}, {"id":"sub 3"}]}, {"id":"sub menu 2", "caption":"sub menu 2", "add":"[Ctrl+T]", "sub":["sub 3", "sub 4"]}], "caption":"menu2"}])
                .onMenuSelected("mnuBar_onmenuselected")
            );
           
           
            return children;
            // ]]code created by jsLinb UI Builder
        },
        mnuBar_onmenuselected : function (profile, popProfile, item, src) {         
            var ns = this, uictrl = profile.boxing();
            switch (item.id)
            {
                case 'mnuClientManager':
                   caption = 'Client Manager';
                   modulefile = 'clientmanager.html';
                   break;
            }
           
            ns.mnuBar.setVisibility("hidden",true);
            var dlg = new linb.UI.Dialog({caption:caption,status:"max",iframeAutoLoad:modulefile});
            // set a refrence into dlg
            dlg._MenuBar=ns.mnuBar;
            dlg.beforeClose(ns.ChildWindow_Closed);
            dlg.showModal();
        },
        ChildWindow_Closed : function(profile)
        {
            var uictrl = profile.boxing();
            // get the refrence
            uictrl._MenuBar.setVisibility("visible",true);
        }
    }
});
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!