Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Mar 2010
    Posts
    25
    Vote Rating
    1
    BigSeanDawg is on a distinguished road

      0  

    Default "this.indexOf is not a function" error with 3.4.0 and creating a Ext.menu.Menu

    "this.indexOf is not a function" error with 3.4.0 and creating a Ext.menu.Menu


    Hi there,

    I have an error happening with my Ext.menu.Menu. It appears the menu's "remove" method is somehow being sent over to the Array.prototype's remove method, which calls "this.indexOf", which isn't defined for the menu. This below code works in 3.3.1, but errors out in 3.4.0:

    Code:
    <html>
    <head>
      <title>Sample Widget Test</title>
      
        <link rel="stylesheet" type="text/css" href="/js/ext-3.4.0/resources/css/ext-all.css"/>
        
          <script  src="/js/ext-3.4.0/adapter/ext/ext-base-debug.js"></script>
        <script  src="/js/ext-3.4.0/ext-all-debug.js"></script>
        
          <script type = "text/javascript">
              Ext.ns('MyApp');
              
              MyApp.ReviewHeader = Ext.extend(Ext.Container, {
                  
                  initComponent: function() {
                      Ext.apply(this, {
                          height: 45,
                          html: 'My Custom Container',
                          mybuttons: [{
                            text: 'Tools',
                            id: 'my-tools',
                            iconCls: 'white-wrench-icon',
                            mymenu: new Ext.menu.Menu(this.getToolsMenu())
                        }]
                      })
                      
                      MyApp.ReviewHeader.superclass.initComponent.call(this);
                  },
                  
                  getToolsMenu: function() {
                      var tools = [{
                          text: "Finish Review",
                          id: 'tools-finish',
                          handler: Ext.emptyFn,
                          icon: 'img/16/award_star_bronze_3.png'
                      }];
                      return tools;
                  }
                  
              });
          
              
            Ext.onReady(function() {
                Ext.QuickTips.init();
                var w = new Ext.Window({
                    title: 'Sample Widget Window',
                    width: 800,
                    height: 600,
                    items: [
                        new MyApp.ReviewHeader(),
                        new Ext.Panel({
                              title: 'Sample Title',
                              html: 'Sample Test Panel'
                          })
                    ]
                });
                
                w.show();
            });
          </script>
        
    </head>
    <body>
    </body>
    </html>
    The above code is greatly simplified from my actual usage, but still shows the error I'm seeing.

    I can make the code work by applying the following override:

    Code:
            Ext.override(Ext.menu.Menu, {
                getMenuItem: function(config) {
                    //config.ownerCt = this;
                    
                    if (!config.isXType) {
                        if (!config.xtype && Ext.isBoolean(config.checked)) {
                            return new Ext.menu.CheckItem(config);
                        }
                        return Ext.create(config, this.defaultType);
                    }
                    return config;
                }
            });
    Here I'm commenting out "config.ownerCt = this", which is a line that was added between 3.3.1 and 3.4.0. Obviously, though, I'm not sure of the ramifications of this line. I had seen a few changes related to menus and ownerCts.

    Is this a known bug? Am I doing something bad to mess it up? Is this an okay override?

    Thanks Sencha! I love Ext!

  2. #2
    Sencha User
    Join Date
    Mar 2010
    Posts
    25
    Vote Rating
    1
    BigSeanDawg is on a distinguished road

      0  

    Default


    After digging through code a little more, I found a better way to get this working. Pass the menu items array in as the "items" attribute of a configuration object:

    Code:
    mymenu: new Ext.menu.Menu({
        items: this.getToolsMenu()
    })
    It appears that this issue only happens when an Ext.menu.Menu is created with an array as its solo constructor argument. I guess this sort of begins to explain how since an array has the "remove" prototype method, if you pass that as the configuration for a container, it might take and override its own "remove" method. However, it doesn't jump out at me as to why the code changes for 3.4 broke this.

    Anyway, the Ext.menu.Menu constructor documentation doesn't say that an array is a valid constructor argument, so perhaps this won't be considered a bug. I'm not sure which one of our developers wrote this code, but they had reason to believe it took an array (perhaps one of the old examples showed this?), and the Ext.menu.Menu code is definitely trying to handle the case of an array being passed in, so something isn't quite working right.

    Hope this helps the next person who stumbles across this issue!

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar