This article describes how jqueryuidialog replaces confirm, and analyzes the steps and implementation skills for simulating the confirm function of the dialog of jQueryui plug-in based on examples, for more information about how to replace confirm with jquery ui dialog, see the examples in this article. We will share this with you for your reference. The details are as follows:
Js confirm, some browsers will shield it directly, leading to unavailability of functions. we recommend that you use the dialog function of jquery ui to perfectly replace the confirm function.
1. html code
Put the above code in a public place
2. simulate confirm js code
Var common = {confirm_act: function (dialog_id, msg, callback) {$ ("#" nvidialog_id=.html (""+ Msg +"
"); $ (" # "+ Dialog_id ). dialog ({resizable: false, modal: true, overlay: {backgroundColor: '# 000', opacity: 0.5}, buttons: {'confirmed': function () {callback. call (); $ (this ). dialog ('close');}, 'cancel': function () {$ (this ). dialog ('close ');}}});}}
A confirm_act method is defined and put into the common js file. The first parameter is the ID of the bullet layer, the second parameter is the prompt message, and the third parameter is the callback function.
Note: When calling a callback function, use the call () function of js. This callback function can contain parameters or callback functions.
3. callback js code
Var recommend = {delete: function (url, obj) {$. ajax ({url: url, type: "get", success: function (data ){............ omitted ..........}});}}
4. how to call
$ ('. Recommended_delete '). click (function () {var obj = this; // rename common. confirm_act ('confirm _ dialog ', $ (obj ). attr ('MSG '), function () {recommend. delete ($ (obj ). attr ('URL'), obj )});});
Note: If this is to be passed in the function, be sure to redefine it..