View Full Version : [FIXED][3.x] Element.insertAfter()
We've recently switched over to using the Ext 3.0 and I've noticed an issue with the insertAfter() method. It appears that it's not using the Elements.insertAfter() but rather the DomHelper's insertAfter() which seems to perform a totally different function. I'm using the same functionality to preform an insertBefore(), and it behave perfect. Please advise.
Can you post a test case? Thanks.
So here's the method I use to determine where to place the node. When I ran this using Ext 2, clickedRow would be the element that was selected to be moved and nextsibling would be clickedRow.dom.nextSibling.
rowMoveDown : function(obj,rowid){
var temp = rowid.toString()
var clickedRow = obj.getRow(obj,rowid)
var currentRow = null;
var nextsibling = Ext.get(clickedRow.dom.nextSibling);
var display_order = Ext.get(obj.type+'_display_order_' + temp);
var display_order_next;
obj.setSmallArrow(obj,temp)
//MAKE SURE THAT THIS ISN'T THE FIRST ROW
if (nextsibling.id != obj.type+'_row_end') {
//SWITCH THE HIDDEN FIELDS OF THE DISPLAY ORDER
var tempnextsiblingid = obj.getRowID(obj,nextsibling.id)
display_order_next = Ext.get(obj.type+'_display_order_' + tempnextsiblingid);
obj.setDisplayOrderField(obj, display_order, display_order_next)
var previoussibling = Ext.get(clickedRow.dom.previousSibling)
var nextsibling2 = Ext.get(nextsibling.dom.nextSibling)
if (previoussibling.id == obj.type+'_header_row') {
obj.setLargeArrowDown(obj,tempnextsiblingid)
}
//IF THIS IS THE LOWEST NUMBER IN THE RUNG
if (nextsibling2.id == obj.type+'_row_end' || nextsibling2.dom.style.display == 'none') {
obj.setSmallArrow(obj,tempnextsiblingid)
obj.setLargeArrowUp(obj,temp)
}
else {
obj.setSmallArrow(obj,temp)
}
clickedRow.insertAfter(nextsibling);
}
}
Condor
4 May 2009, 7:26 AM
There is something wrong with Element.insertAfter if the passed element isn't a DOM node:
It needs:
Ext.Element.addMethods(function() {
var GETDOM = Ext.getDom;
return {
insertAfter: function(el){
(el = GETDOM(el)).parentNode.insertBefore(this.dom, el.nextSibling);
return this;
}
}
}());
I've update the code to
clickedRow.insertAfter(nextsibling.dom); and that seemed to do the trick. So why doesn't clickedRow.insertBefore work in the same manor?
Condor
4 May 2009, 8:06 AM
Your original code should have worked. Both insertBefore and insertAfter should allow a Ext.Element, a DOM node and or a node id as parameter.
aconran
5 May 2009, 9:29 AM
Thanks, fixed in revision 287 of Ext Core.
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.