Documentation

BX.ready

void 
BX.ready(
 Function handler
);

This function adds the DOM-structure available to write event handler. Shorter version – BX(Function handler).

Example

<?
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php");
$APPLICATION->SetTitle("Events");
   CJSCore::Init();
?>
<a href="http://bitrix24.com" class="css_bind" data-param="HELLO" >click Me</a>
<div class="css_bind" data-param="HELLO2">click Me2</div>

<script>
BX.ready(function(){
   var param1 = ' global Hello';
   BX.bindDelegate(
      document.body, 'click', {className: 'css_bind' },
      function(e){
         if(!e)
            e = window.event;
         
         alert(this.getAttribute('data-param')+param1);
         return BX.PreventDefault(e);
      }
   );
});
</script>
<?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php");?>


© «Bitrix24», 2001-2024
Up