Disable Function as Event Handler BX24.unbind

Choose a tool for developing with an AI agent:

  • use Alaio Vibecode to build an app for Bitrix24 from a task description without knowing any programming language. The agent writes the code and deploys the app to a server, with no manual hosting setup
  • use the MCP server to develop a REST API integration in your own project. The agent refers to the official REST documentation
BX24.unbind(element: object, eventName: string, func: callable): void;
        

The BX24.unbind method removes the handler func of the eventName event, assigned by BX24.bind, from the page element element.

The method works on an application page where the BX24.js library is connected and does not call Bitrix24. The method requires no scope of its own.

A handler can be removed only by passing the same function reference that was passed to BX24.bind. If you pass a new function, even one with the same code, the handler remains, and there is no error. Therefore, store a function that you will need to remove in a variable or create it with BX24.proxy.

Method Parameters

Required parameters are marked with *

Name
type

Description

element*
object

The page element from which the handler needs to be removed

eventName*
string

The event name without the on prefix, for example, click. For mousewheel, the method also removes the handler from the DOMMouseScroll event

func*
callable

The same function that was passed to BX24.bind

Code Example

How to Use Examples in Documentation

A handler that fires only once:

<button id="run-action">Run</button>
        
        <script>
            BX24.ready(function () {
                const button = document.getElementById('run-action');
        
                function onClick() {
                    console.log('Button clicked');
                    BX24.unbind(button, 'click', onClick);
                }
        
                BX24.bind(button, 'click', onClick);
            });
        </script>
        

Response Handling

The method does not return data (void).

Error Handling

The method does not return error codes. If there is nothing to remove, the method does nothing.

Situation

What Happens

What to Do

The handler was assigned to the transitionend event

The method removes the handler only from transitionend. It is not removed from the webkitTransitionEnd, msTransitionEnd, and oTransitionEnd events that BX24.bind added

Remove the handler from each of these events with a separate BX24.unbind call

null is passed in element

Nothing happens, and there is no error

Pass a page element

Continue Learning