1

--------------------- Solution ---------------------------

I did a workaround of having to callParent inside my code,

 var expandFieldOverride = function(event)
{
    //event: collapse, false / expand, true 
    var fieldset = this; 
    var arguments = [event]; 

    if(!fieldset.readyToExpand){            
        Ext.each(profilesPanel.items.items, function(panel, i)
        {       
            if (panel.isProfilePanel)
            {
                    console.log(event); 
                    var field = panel.down('profileform[title=Standard Configuration]').down('fieldset[name='+fieldset.name+']');
                    field.readyToExpand = true; 
                    field.setExpanded(event); 
            }           
        });
    }
    this.callParent(arguments); 
    fieldset.readyToExpand = false; 
}

-------------------------Initial Problem-------------------------------

I am using ExtJS 4.2.1 and I am trying to override the collapse and expand events of fieldsets. Using collapse and expand didn't work, so I had to directly override setExpanded(). I am trying to achieve the event that when one fieldset is collapsed in a profile panel, so is the other in the other profile panel, and vice versa.

 Ext.define('EcoCentral.Configuration.ThermostatProfiles.ProfileOptionsFieldSet',
{
    extend: 'Ext.form.FieldSet',
    setExpanded: expandFieldOverride,
    //expand: expandFieldOverride,
    //collapse: collapseFieldOverride,
    alias: 'widget.profilefieldset'

});

 var expandFieldOverride = function(event)
{
    //this.callParent(arguments);
    //event: collapse, false / expand, true 
    var fieldset = this; 
    var arguments = [event]; 

    Ext.each(profilesPanel.items.items, function(panel, i)
    {       
        if (panel.isProfilePanel)
        {
            var field = panel.down('profileform[title=Standard Configuration]').down('fieldset[name='+fieldset.name+']');
            console.log(field); 
            //field.callParent(arguments); 
            field.self.superclass.setExpanded.call(arguments); 
        }
        //this.callParent(arguments); 
    });
}

If I use 'this.callParent(arguments)' inside the code, I recieve 'Uncaught TypeError: Cannot read property 'superclass' of undefined '

I did some research and tried out this line of code 'field.self.superclass.setExpanded.call(arguments);' from which I recieve : 'Uncaught TypeError: Object # has no method 'addCls''

Which is a call inside of the setExpanded function in the source.

 setExpanded: function(expanded) {
    var me = this,
        checkboxCmp = me.checkboxCmp,
        operation = expanded ? 'expand' : 'collapse';

    if (!me.rendered || me.fireEvent('before' + operation, me) !== false) {
        expanded = !!expanded;

        if (checkboxCmp) {
            checkboxCmp.setValue(expanded);
        }

        if (expanded) {
            me.removeCls(me.baseCls + '-collapsed');
        } else {
            me.addCls(me.baseCls + '-collapsed');
        }
        me.collapsed = !expanded;
        if (expanded) {
            delete me.getHierarchyState().collapsed;
        } else {
            me.getHierarchyState().collapsed = true;
        }
        if (me.rendered) {
            // say explicitly we are not root because when we have a fixed/configured height
            // our ownerLayout would say we are root and so would not have it's height
            // updated since it's not included in the layout cycle
            me.updateLayout({ isRoot: false });
            me.fireEvent(operation, me);
        }
    }
    return me;
},

My fieldset is defined by xtype:


Here's a showcase for a jQuery plugin that does exactly what you're looking for: http://johnpolacek.github.io/scrolldeck.js/decks/parallax/

Here's the direct link to the plugin: https://github.com/IanLunn/jQuery-Parallax

4

1 回答 1

0

你必须使用申请。调用是错误的功能。看看这个:

call 和 apply 和有什么不一样?

于 2013-08-14T17:36:06.460 回答