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,246
    Vote Rating
    89
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      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,823
    Vote Rating
    608
    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

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi