PDA

View Full Version : CompositeElement and hover method



andycramb
14 Aug 2009, 1:26 AM
I am trying to use the hover method on a mixed collection. It does not fire when I hove over one of the elements in the collection. I put a breakpoint in the code mouseover function and it does not get hit but when I run
Ext.select('.editableCell'); in the firebug console I can inspect the MixedCollection object and see the hover method.

The API states that the MixedCollextion
supports all of the set/update methods of Ext.Element. I assume that this means the hover method is not supported? I am not sure what are the set/update methods?



var edEl = Ext.select('.editableCell');
edEl.hover(function(){
console.log('addClass');
this.addClass('editableCellBg');
},
function(){
this.removeClass('editableCellBg');
},this);

Animal
14 Aug 2009, 1:44 AM
The code



Ext.get("div").addClassOnOver("hover-class");


works for me. Any div I put the mouse over gets this class added until I mouse out.

andycramb
14 Aug 2009, 1:50 AM
Thanks Animal

The problem I am having is I am trying to use it on an editable cell and I am trying to toggle the style of the td element. In the grid inside the td is a div so when I mouse over the div it toggles the class as the mouseout event fires.
I was trying to use the EventObject as I believe I can use the within method to get round this.
I thought I could use the hover method on the collection but I may have to go down the line of attaching mouseover and mouseout events to each element and then use within to get round the child div of the td?

Animal
14 Aug 2009, 1:51 AM
Your code "works", but what it does is cause a huge loop adding the class to every item in the Composite whenever you mouseover ANY SINGLE ONE OF THEM.

Animal
14 Aug 2009, 1:53 AM
You will have to use a mouseover listener on the GridView's mainBody, and emulate the mouseenter code to filter when the mouse if ENTERING a TD (as opposed to a bubbled mouseover from any other element)

This is what the requested cellmouseover and cellmouseout events will have to do. I have added a request that these be added.

andycramb
14 Aug 2009, 2:01 AM
Thanks
That is where I thought I might have to do
I will give that a go