YMC-22 / smart-filter

YMC Smart Filter, allows to solve a variety of tasks for displaying posts on site pages. For advanced developers, there is an opportunity to independently develop layouts for filters and post cards, which makes the plugin universal.
14 stars 6 forks source link

Namespace for event handlers in jQuery #5

Closed Triloworld closed 1 year ago

Triloworld commented 1 year ago

I mean that this file: https://github.com/YMC-22/smart-filter/blob/main/includes/assets/js/script.js have click (and other too) handlers described like this example: .on('click', (https://github.com/YMC-22/smart-filter/blob/main/includes/assets/js/script.js#L854)

Should be like this example (name can be different) : .on('click.ymc_smart_filter',

This will enable manage handlers as they have names. Work as namespace in jQuery

We have one field that requires it to be added as two separate fields and work independently. Now we cannot remove smart filters without a rewiring function. When namespace will be added we can remove the handler by name and add our to have part with activate more filters and separate to send requests.

Triloworld commented 1 year ago

There is 5 menu-link handlers. Nees unique names to disable only sending request. We do it on button

YMC-22 commented 1 year ago

Hello! We have made some changes to the name of event handlers (click). Now you can detach the click event handler on the filter buttons using the construct, for example: $("#element").off("click.ymc_smart_filter"); The name of the handler for all elements (buttons) is click.ymc_smart_filter. We hope this will help you in solving your task.