Custom Confirm Plugins
Custom Confirm Plugins
Idea: 1. Event action: Displays a div layer with ID myconfirm and returns false;
2. Event Action: callback function call Trigger () method to automatically execute the event, change status value, return to status;
var status=false;//is defined as a Global object: Records dialog execution State
$.fn. Myconfirm = function ($CLICKOBJ, $DIALOGOBJ) {
$DIALOGOBJ. Dialog (
{title: ' Confirm Box ',
Position: [100, 100],
Modal:true,
Buttons: {
' OK ': function () {
$DIALOGOBJ. Dialog (' Close ');
Status=true;
Callback ($CLICKOBJ, True, $DIALOGOBJ);
},
' Cancle ': function () {
$DIALOGOBJ. Dialog (' Close ');
Status=false;
Callback ($CLICKOBJ, False, $DIALOGOBJ);
}
},
}
);
$dialogObj. Text ("OK to delete?") ");
return status;
}
function callback ($CLICKOBJ, status, $DIALOGOBJ) {
if ($CLICKOBJ)
{
if (status==true) {
$CLICKOBJ. Trigger (' click ');
}
$DIALOGOBJ. Dialog (' Close ');
}
}
Test
<script type= "Text/javascript" >
Test
$ (function () {
$ ("#Btn"). Click (function () {
Return $.FN. Myconfirm ($ (' #Btn '), $ ("#myConfirm"));
});
});
</script>
HTML page:
<form id= "Form1" runat= "Server" >
<div id= ' myconfirm ' >
</div>
Name:<asp:textbox id= "TextBox1" runat= "Server" ></asp:TextBox>
<asp:label id= "Label1" runat= "Server" text= "Label" ></asp:Label>
<asp:button id= "Btn" runat= "Server" text= "Submit" clientidmode= "Static" onclick= "Btn_click" >
</asp:Button>
</form>
jquery Custom Confirm