Posts tagged with: native

Unobtrusive Confirm Javascript Replacement with jquery UI Dialog

Today I needed to implement an unobstrusive replacement for native alert and confirm functions for a client’s project. I searched a lot of libs and solutions but none of them worked as I wanted. So I decided to at least try to implement one real unosbtrusive replacement.

Here we go. First we need jQuery, jQuery UI Core (core, widget, position) and widget (dialog), choose any theme and we are set.

Take a look at the code below:

After that i need to overload the native confirm function. Check the next code:

Note that this function you can customize whatever you want, but here I’m using jQuery UI Dialog. You can try your own if you want, just pay attention on line 13, when I throw the callback. Of course, this is the first draft of workaround, maybe someone can increment the idea.

Heres the full code:

Did you like this? Share it: