BX.bindDelegate
Function BX.bindDelegate( DOMNode node, String eventName, Object isTarget, Function handler );
The function sets the event handler for the eventName to the node child elements, satisfying to the isTarget conditions. This method nuance is the independency from the changes n the node content: the handler itself is assigned to the node and accepts an event when it pops up from the child elements.
Function parameters
Parameter | Descripton |
---|---|
node | Parent node |
eventName | Event name |
isTarget | Description of child nodes in a format, similar to to search functions format |
handler | Event handler |
Returned value
Link to the actually defined event handler, which can be used, for example, for [link=654133]BX.unbind[/link].
Examples of use
<style>#my_node td {padding: 2px; height: 30px; width: 30px; text-align: center;}</style> <table id="my_node" cellpadding="2" cellspacing="0" border="1"> <tr><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td></tr> </table> <script> var sign = 'x'; BX.bindDelegate( BX('my_node'), 'click', { tagName: 'TD' }, function() { this.innerHTML = sign; sign = sign == 'x' ? 'o' : 'x'; } ); </script>
© «Bitrix24», 2001-2024