How to set events in jQuery.on function

Looking at the bootstrap library, I see that when using the .on function,
the event is recorded as follows:

$(document).on('click.button.data-api', '[data-toggle^=button]', function (e) { // some code }) 

What is the purpose of recording an event as click.button.data-api instead of click ?
Is click enough?

+4
source share
1 answer

"button" and "data-api" are event namespaces separated . after the name of the event.

Of course, it will only work with "click" , but this will break unrelated code when bootstrap disables the data API using .off("click") . In namespaces, they can call .off("click.data-api") to remove only events belonging to boot-api data.

+5
source

Source: https://habr.com/ru/post/1444610/


All Articles