PDA

View Full Version : Workaround for a bug in ext 3.4.1.1 Ext.dd.DragDropMgr



pegaso52it
14 Oct 2013, 5:43 AM
Hi all, is there a problem in code of function getZIndex of Ext.dd.DragDropMgr version 3.4.1.1
after the "while (element !== body) " statement is missed: if (element == null) return -1;
because in some scenarios element might be null.

I've tryed to override the function duing this:

Ext.override(Ext.dd.DragDropMgr,
{
getZIndex: function(element) {
var body = document.body,
z,
zIndex = -1;

element = Ext.getDom(element);
while (element !== body) {
//this is the live I've added
if (element == null) return -1;
if (!isNaN(z = Number(Ext.fly(element).getStyle('zIndex')))) {
zIndex = z;
}
element = element.parentNode;
}
return zIndex;
}
});


But I got Ext errors during runtime.
My question is : Is there a way to add my fix externally. e.g. using override to not change the ext original code?

Thanks

silentsakky
15 Oct 2013, 1:03 AM
Ext.apply(Ext.dd.DragDropMgr,
{
getZIndex: function(element)
{
var body = document.body,
z,
zIndex = -1;

element = Ext.getDom(element);
while (element !== body) {
//this is the live I've added
if (element == null) return -1;
if (!isNaN(z = Number(Ext.fly(element).getStyle('zIndex')))) {
zIndex = z;
}
element = element.parentNode;
}
return zIndex;
}
});


Ext.dd.DragDropMgr is a singleton so you can't use Ext.override on it, you must use Ext.apply for overriding a method of a singleton

pegaso52it
15 Oct 2013, 5:54 AM
Thanks for suggestion, it works.

smolin
7 Jan 2014, 4:25 AM
I think you have some D&D target components destroyed but still registered. I mean you should call unreg() for the targets you dont need, not just destroy them. Ext.dd.DragDropMgr tries to work with such targets in its fireEvents method hence the error you got as some DOM elements dont exist at the moment. Method getZIndex is allright, you dont need to override it.