Skip to content
  • Andrew Lyons's avatar
    MDL-70990 core_filter: Add new native filterContentUpdated event · d4c6ac20
    Andrew Lyons authored
    The legacy M.core.event.FILTER_CONTENT_UPDATED event has been replaced with a
    new core_filter/events::filterContentUpdated native DOM event.
    
    The new event can be triggered using the `notifyFilterContentUpdated`
    function, and by providing with an Array containing the HTMLElements
    that were updated, for example:
    
    ```
    import {notifyFilterContentUpdated} from 'core_filter/events';
    
    const someHandler = e => {
        // ...
        const nodeList = Array.from(document.querySelectorAll('div'));
        notifyFilterContentUpdated(nodeList);
    };
    ```
    
    The new event can be listened to at any point in the DOM using the
    following syntax:
    
    ```
    import {eventTypes} from 'core_filter/events';
    
    const handler = e => {
        // The list of HTMLElements in an Array.
        e.detail.nodes;
    };
    
    document.addEventListener(eventTypes.filterContentUpdated, handler);
    ```
    
    A backward-compatabibility layer is included to ensure that any legacy
    YUI event listener, or jQuery event listener are still called with the
    same arguments.
    
    This legacy bridges will be removed after Moodle 4.3.
    d4c6ac20