Retreive htlm code pointed by the mouse inside an element

Hello,

I have an element in which I don't want to create additionnal other elements.

The viewNode of this element is an array. I have defined an event handler (click) which I would like to use to perform actions depending of the the row of the array clicked (tr tag). Indeed, I would like to retrieve the content of the tr tag which is clicked to perform different actions.

Is it posible without creating additionnal elements in the parent element ?

Thanks a lot.

RE: retrieving html code pointed by the mouse inside an element

Umm... not sure exactly what you mean here. It sounds like you are trying to figure out which <tr> was clicked when the user clicks in a table?

You can use $event/property::target to determine what was clicked. This will be a <td>. To get the <tr> you can use XPath to get the <td>'s ancestor, like this:

<e:handler event="click">
  <e:variable name="row" select="$event/property::target/ancestor::tr[1]" />
     
   <!-- following alert will display "HTMLTableRowElement" or something similar -->
   <c:alert select="row" />
</e:handler>

or in javascript:

<e:handler event="click" type="text/javascript">
    var row = bb.evaluateSmart("ancestor::tr[1]",event.getProperty('target'))
   
    // this alternate way of getting the row should work too...
    // var row = event.getProperty('target').modelNode.parentNode
   
    //following alert will display "HTMLTableRowElement" or something similar
    alert(row)
</e:handler>

Once you have the target row you can again use XPath to get at attributes, text content, child nodes, etc.

Hope this helps.