We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33968
    • 863 Posts
    I’m going a bit crazy here, been trying for hours and no result...

    I have a tbar button set to open a MODx.Window but when I click the button I get no window.

    Code (additional functions removed):
    LandRover.tree.HomeRun = function(config) {
        config = config || {};
        Ext.applyIf(config,{
            rootVisible: false
            ,rootName: _('homerun.builders')
            ,root_id: 'n_root_0'
            ,title: _('homerun.builders')
            ,ddAppendOnly: true
            ,expandFirst: true
            ,enableDrag: true
            ,enableDrop: true
            ,url: LandRover.config.connectorUrl
            ,action: 'mgr/homes/getNodes'
            ,primaryKey: 'id'
            ,useDefaultToolbar: true
            ,tbar: [{
                text: _('new')+' '+_('homerun.home')
                ,handler: { xtype: 'landrover-window-home-create' ,blankValues: true }
            }]
        });
        LandRover.tree.HomeRun.superclass.constructor.call(this,config);
    };
    Ext.extend(LandRover.tree.HomeRun,MODx.tree.Tree);
    Ext.reg('landrover-tree-homerun',LandRover.tree.HomeRun);
    
    
    LandRover.window.CreateHome = function(config) {
        config = config || {};
        Ext.applyIf(config,{
            title: _('homerun.home_new')
            ,url: LandRover.config.connectorUrl
            ,baseParams: {
                action: 'mgr/homes/create'
            }
    		,fields: [{
    		    xtype: 'textfield'
    		    ,fieldLabel: _('homerun.home_name')
    		    ,name: 'name'
    		    ,width: 200
    		}]
    	});
    	LandRover.window.CreateHome.superclass.constructor.call(this,config);
    };
    Ext.extend(LandRover.window.CreateHome,MODx.Window);
    Ext.reg('landrover-window-home-create',LandRover.window.CreateHome);
    


    The problem is with the LandRover.window.CreateHome function and the ’landrover-window-home-create’ xtype.

    I get this error message from Firebug:

    this.handler is not a function
    ERROR: onFunctionCall ERROR invalid context


    The infuriating thing is I paste this function (and tbar settings) into a different CMP and it works perfectly huh

    Any ideas would be really appreciated!!
      • 33968
      • 863 Posts
      Actually, if anyone can drop me some tips on debugging javascript or just point me in the right direction that would be awesome.

      Like I said, the function is working in one CMP but not in another. I’ve tried changing the function name to rule out conflicts (among many other combinations) and that doesn’t make a difference.
      It’s also not affected by the tree.Tree instance as I’ve tried it alone on a panel.

      I also tried replacing the xtype reference with a direct call to the function like this:
      ,handler: LandRover.window.CreateHome
      

      And the error changes to:
      this._loadForm is not a function

      Not sure if that provides a clue at all...
        • 33968
        • 863 Posts
        Chrome dev toolbar gives me this error:
        ext-all.js:7
        Uncaught TypeError: Object #<Object> has no method ’call’
        Ext.Button.Ext.extend.onClick
        J


        I’m completely baffled. Anyone out there?!
          • 32316
          • 387 Posts
          if the function is working in a different CMP then the function code is probably ok.
          So it is the other code which has the problem - or at least the interaction of the two

          What is different about the different CMPs

          hope this is a clue and helps
            • 33968
            • 863 Posts
            Hi whistlemaker - thanks for the suggestion, I’ve arrived at more or less the same conclusion but just finding it a nightmare to pinpoint the problem. I can’t get any useful debug information and am not very experienced with javascript.

            The difference here is this CMP contains a Tree layout while the other uses a Grid. I’d wondered if there was some issue to do with the Tree tbar section.

            Will just have to keep trying or perhaps build it all up from scratch again (uff!).