How to pass a Jquery plugin as a parameter for the On event

Asked

Viewed 54 times

0

I use the Datatables plugin, and in the table there will be the option to edit and delete, I want to show a confirmation if the user click delete. Therefore, I will use the plugin "confirm", however, this plugin is only valid for the first page of Datatable, on other pages or when I do a search it does not work. I thought about the event "on", but how do I pass the plugin "confirm" instead of the function (3rd parameter).

Something like:

$("html").on("click", ".confirm", $.confirm());
  • You can test without calling the function... $("html").on("click", ".confirm", $.confirm);. If it doesn’t work please indicate which plugin is this and where is the documentation and source code so we can better understand the plugin and the problem.

  • I cannot invoke without the parameters, by using them (passing the message, buttons, etc)... The plugin in question is the following: http://myclabs.github.io/jquery.confirm/

  • tried $("html"). on("click", ". confirm", Function(){ $(this). confirm() }); ?

  • I had already tried this way, so it only works in the second click :/

1 answer

2


You can pass a function that calls the $.confirm. For example:

$("#elemento").on("click", function() {
    $.confirm();
});
  • When I saw your comment I thought: "That’s it!"... But when executing the code, it didn’t work either... Same problem, works on the first page, but on the second does not work :(

  • Thanks, only one parameter was missing in your reply... This is how it worked: $("html"). on("click", ". confirm", Function(){ $. confirm() });

Browser other questions tagged

You are not signed in. Login or sign up in order to post.