jquery Custom Confirm

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.