Results 1 to 1 of 1

Thread: [3.3.0] Ext.decode vs direct eval call

  1. #1

    Question [3.3.0] Ext.decode vs direct eval call

    Hi all. Viewport does an Ext.direct call to php backend for menu contents and handler methods are returned as json text.

    PHP Code:
            if(COI.userProfile.showribbon != "off") {
                function 
    loadRibbon(jsone){
                    if(
    e.status){
                        
    Ext.apply(thisExt.util.JSON.decode(json.data.methods));
                        
    ribbonBar = new Ext.ux.Ribbon({ 
                            
    itemsExt.util.JSON.decode(json.data.items),
                        });
                        
    this.COI_NorthPanel.getTopToolbar().add(ribbonBar);
                        
    this.doLayout();
                    }
                }
                
    COI.modmgr.loadRibbonMenu(COI.userProfileloadRibbonthis);
            } 
    The above code loads the menu and presents correctly. However, my applied methods are not available to my menu handler routines. Reports that the handler is not a function.

    Change to

    PHP Code:
            if(COI.userProfile.showribbon != "off") {
                function 
    loadRibbon(jsone){
                    if(
    e.status){
                        eval(
    "Ext.apply(this, "+json.data.methods+");");
                        eval(
    "this.ribbonBar = new Ext.ux.Ribbon({ items : "+json.data.items+"});");
                        
    this.COI_NorthPanel.getTopToolbar().add(this.ribbonBar);
                        
    this.doLayout();
                    }
                }
                
    COI.modmgr.loadRibbonMenu(COI.userProfileloadRibbonthis);
            } 
    And everything works fine. I can reference "this" in my remote methods and handlers. Why is Ext losing scope on the Ext.decode method call? I tried Ext.decode.call(this, json.data.methods) with no change. Since extjs ultimately performs an eval in the decode method I don't understand why there is a disparity between the two versions. Anybody shed any light on this for me? I appreciate your time, I don't know why I would rather let extjs do an "eval" than do it myself

    Have a great day!
    Dan
    Last edited by danellison; 11 May 2011 at 10:16 AM. Reason: clarification

Similar Threads

  1. Changing the url for a Direct call
    By eVizions in forum Ext.Direct
    Replies: 7
    Last Post: 25 Jun 2009, 12:36 PM
  2. [2.??] Ext naively uses eval to decode JSON.
    By pbuyle in forum Community Discussion
    Replies: 2
    Last Post: 11 Jul 2008, 10:13 PM
  3. [2.??] Ext naively uses eval to decode JSON.
    By pbuyle in forum Ext 2.x: Bugs
    Replies: 2
    Last Post: 11 Jul 2008, 10:13 PM
  4. Ext.decode instead of local eval
    By mdissel in forum Community Discussion
    Replies: 4
    Last Post: 19 Jul 2007, 12:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •