Documentation

Events

General principles

Events are generated during the complete slider life cycle (opening-loading-closing-destroying). Events are sent to both parent window and the iframe. If the slider has the arbitrary content, events are generated only in the parent window.

There are two variants of subscription to events.

  • Global subscription.
     BX.addCustomEvent("SidePanel.Slider:onOpen", function(event) {
          console.log(event.getSlider()); //gets the slider object
        });
    • This event will be generated for all sliders at the parent page. The getUrl() or getData() methods can be used to define a specific slider in the handler.
    • If the handler is specified inside the iframe, it can be executed only within the specific slider.
    • Full event name is used to assign the handler.
  • Subscription on events for a specific slider.
     BX.SidePanel.Instance.open("/crm/button/edit/10/", {
           events: {
              onLoad: function(event) {
                 console.log("onLoad");
              }
           }
        });
    • Event handler will be executed only for the specified slider.
    • Short event name is used to assign the handler.

Example

Example of assigning a handler in BX.SidePanel.Instance.bindAnchors.

BX.SidePanel.Instance.bindAnchors({
       rules: [
          {
             condition: [
                "/crm/button/edit/(\d+)/"
             ],
             options: {
                cacheable: false,
                width: 900,
                events: {
                   onLoad: function(event) {
                      console.log("onLoad");
                   }
                }
             }
          }
       ]
    });

Developers retrieve a BX.SidePanel.Event event type object in the first argument.

BX.addCustomEvent("SidePanel.Slider:onCloseComplete", function(event) {
   console.log(event.getSlider()); //get the slider object
});


© «Bitrix24», 2001-2024
Up