1. #1
    Ext JS Premium Member
    Join Date
    Oct 2007
    Location
    Herndon, VA
    Posts
    265
    Vote Rating
    3
    durlabh is on a distinguished road

      0  

    Default [FIXED-357][2.x/3.x] Element.insertSibling 'after' with array adds in invalid order

    [FIXED-357][2.x/3.x] Element.insertSibling 'after' with array adds in invalid order


    I was using a DataView bound to a store. If we added multiple records in the store (appended at last), the elements were displaying in wrong order in the DataView. After a little trace, I found that the main culprit seems to be insertSibling method of Ext.Element. If you pass an array, it adds elements one by one resulting the elements being added in reverse order. For this I applied the following fix:

    Code:
    Ext.override(Ext.Element, {
    	insertSibling: function (el, where, returnDom) {
    		var rt;
    		if (Ext.isArray(el)) {
    			// Fix: if where == 'after', it inserts at wrong position
    			var insertEl = this;
    			for (var i = 0, len = el.length; i < len; i++) {
    				rt = insertEl.insertSibling(el[i], where, returnDom);
    				if (where == 'after') {
    					insertEl = Ext.get(rt);
    				}
    			}
    			return rt;
    		}
    		where = where ? where.toLowerCase() : 'before';
    		el = el || {};
    		var refNode = where == 'before' ? this.dom : this.dom.nextSibling;
    
    		if (el.nodeType || el.dom) { // dh config
    			rt = this.dom.parentNode.insertBefore(Ext.getDom(el), refNode);
    			if (!returnDom) {
    				rt = Ext.get(rt);
    			}
    		} else {
    			if (where == 'after' && !this.dom.nextSibling) {
    				rt = Ext.DomHelper.append(this.dom.parentNode, el, !returnDom);
    			} else {
    				rt = Ext.DomHelper[where == 'after' ? 'insertAfter' : 'insertBefore'](this.dom, el, !returnDom);
    			}
    		}
    		return rt;
    	}
    });

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,251
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      0  

    Default


    Or you could insert them in reverse order:
    Code:
    Ext.apply(Ext.Element.prototype, function() {
        var GETDOM = Ext.getDom,
            GET = Ext.get,
            DH = Ext.DomHelper;
        return {
            insertSibling: function(el, where, returnDom){
                var me = this,
                    rt;
                where = (where || 'before').toLowerCase();
                if(Ext.isArray(el)){
                    for(var i = 0, len = el.length; i < len; i++){
                        rt = me.insertSibling(el[where == 'before' ? i : len - 1 - i], where, returnDom);
                    }
                    return rt;
                }
                el = el || {};
                if(el.nodeType || el.dom){
                    rt = me.dom.parentNode.insertBefore(GETDOM(el), where == 'before' ? me.dom : me.dom.nextSibling);
                    if (!returnDom) {
                        rt = GET(rt);
                    }
                }else{
                    if (where == 'after' && !me.dom.nextSibling) {
                        rt = DH.append(me.dom.parentNode, el, !returnDom);
                    } else {
                        rt = DH[where == 'after' ? 'insertAfter' : 'insertBefore'](me.dom, el, !returnDom);
                    }
                }
                return rt;
            }
        };
    }());

  3. #3
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,127
    Vote Rating
    516
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    This is fixed in SVN, both branches.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

Thread Participants: 2

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