Looking to the bootstrap library I see that when using the .on function,
the event is written in this way:
$(document).on('click.button.data-api', '[data-toggle^=button]', function (e) {
// some code
})
What is the purpose of writing the event as click.button.data-api instead of click ?
Is click enough?
"button"and"data-api"are the event namespaces, separated by.after the event name.Sure it would work with just a
"click", but that will break unrelated code when bootstrap turns data API off with.off("click"). With namespaces, they can call.off("click.data-api")to remove only events that belong to the bootstrap data-api.