Event dispatching - V2
Hi Alex,
I have a question about event dispatching in AW. Please bare with me, this is a slightly
long post :(
'control.js' has an object called 'handlers' that has a list of functions to handle the various mouse events. At the moment I am interested in the 'onclick' handler. It seems to call a function 'RaiseControlEvent(onRowClicked, element, event)'
which in turn calls 'object.raiseEvent(handler, event, a, b, c)'.
(Incidentally, what are the 'a, b, c' arguments used for?)
raiseEvent is responsible for calling the actual event handler method that was defined on the object in question. So in my case, it calls 'grid.onRowClicked(event)'
Are these correct assumptions?
- Back now to the 'onclick' handler function.
It gets a reference to the parent element of the target node that was clicked and performs the same actions as listed above. This process loops around until it has checked all the ancestor nodes of the original target node. i.e. It seems to perform event bubbling back up the chain.
What I do not see during this dispatching process is a means of checking if bubbling of the event in question has been cancelled at some point by one of the handlers. Am I missing something here?
------- Reason for asking -------
I have a grid that when clicked (anywhere in a row) can open a new sub-grid (placed in a DIV that is appended as a child node of the row clicked element...'with thanks to Andreas for his excellent AW-v1 example') displaying another set of data...thus giving me the ability to have a grouped data effect.
Clicking on the new sub-grid can perform another action...display another set of sub-grouped data, display detailed info. about the selected row...whatever.
I click on a row in the sub-grid, that sub-grid processes the event, and then cancels bubbling of the event using the following function:
[code]
if (document.all) {
window.event.cancelBubble = true;
window.event.returnValue = false;
}else if(e.preventDefault){
e.cancelBubble = true;
e.stopPropagation();
e.preventDefault();
}
return false;
[/code>
However, the parent grid still receives the event even after the code above is executed...and of course closes the sub-grid as it sees it as a toggle action. i.e. click a row once to open, click again to close.
Can you shed some light on this process for me please? I urgently need to get this working. I know that I can check the 'cancelBubble' property of the event in my own event handling code, but that's a bit hacky.
I would have thought that if I cancel bubbling I shouldn't receive this event any longer further up the document chain. Have I got this wrong?
Many thanks,
BT
I have a question about event dispatching in AW. Please bare with me, this is a slightly
long post :(
'control.js' has an object called 'handlers' that has a list of functions to handle the various mouse events. At the moment I am interested in the 'onclick' handler. It seems to call a function 'RaiseControlEvent(onRowClicked, element, event)'
which in turn calls 'object.raiseEvent(handler, event, a, b, c)'.
(Incidentally, what are the 'a, b, c' arguments used for?)
raiseEvent is responsible for calling the actual event handler method that was defined on the object in question. So in my case, it calls 'grid.onRowClicked(event)'
Are these correct assumptions?
- Back now to the 'onclick' handler function.
It gets a reference to the parent element of the target node that was clicked and performs the same actions as listed above. This process loops around until it has checked all the ancestor nodes of the original target node. i.e. It seems to perform event bubbling back up the chain.
What I do not see during this dispatching process is a means of checking if bubbling of the event in question has been cancelled at some point by one of the handlers. Am I missing something here?
------- Reason for asking -------
I have a grid that when clicked (anywhere in a row) can open a new sub-grid (placed in a DIV that is appended as a child node of the row clicked element...'with thanks to Andreas for his excellent AW-v1 example') displaying another set of data...thus giving me the ability to have a grouped data effect.
Clicking on the new sub-grid can perform another action...display another set of sub-grouped data, display detailed info. about the selected row...whatever.
I click on a row in the sub-grid, that sub-grid processes the event, and then cancels bubbling of the event using the following function:
[code]
if (document.all) {
window.event.cancelBubble = true;
window.event.returnValue = false;
}else if(e.preventDefault){
e.cancelBubble = true;
e.stopPropagation();
e.preventDefault();
}
return false;
[/code>
However, the parent grid still receives the event even after the code above is executed...and of course closes the sub-grid as it sees it as a toggle action. i.e. click a row once to open, click again to close.
Can you shed some light on this process for me please? I urgently need to get this working. I know that I can check the 'cancelBubble' property of the event in my own event handling code, but that's a bit hacky.
I would have thought that if I cancel bubbling I shouldn't receive this event any longer further up the document chain. Have I got this wrong?
Many thanks,
BT
BT
January 24,