I am trying to create multiple dialog box and some how i am not able to understand how to create those dialog boxes.
I have DIV's for each dialog box which has a message for every action. Basically if user check the CheckBox then dialog appears saying that you want to confirm this action. And after some time if user again uncheck that CheckBox then another dialog appears with the diff message. Please help me with this one.
Here is what i have got so far.
===============
HTML
<div id="dialog-isReceived" title="Mark as Received?">
Are you sure you want to mark this order as "Received"? <br />
The customer will receive an email confirming their order is ready for collection.
</div>
<div id="dialog-notReceived" title="Mark as Not Received?">
Are you sure you want to mark this order as "Not Received"? <br />
</div>
Jquery
var isReceivedCheckBox = $('.isReceivedCheckBox input[type=checkbox]');
var dialogId; //trying to pass the Id of the div dynamically BUT not working
var result;
$(document).ready(function () {
$(dialogId).dialog(
{
autoOpen: false,
width: 300,
height: 200,
resizable: false,
modal: false,
buttons: {
"Confirm": function () {
result = true;
},
Cancel: function () {
result = false;
$(this).dialog("close");
}
},
});
});
=====================
CODE that i want to execute
$(document).on("change",isReceivedCheckBox, function () {
var checked = $(this).is(':checked');
if (checked) {
dialogId = "'#dialog-isReceived'"; //setting the DIV ID here and hoping that dialog will appears.
$(dialogId).dialog('open');
if(!result)
$(this).attr("checked", false); // if user clicks cancel on dialog then do not check the checkbox
} else {
dialogId = "'#dialog-notReceived'";
$(dialogId).dialog('open');
if(!result)
$(this).attr("checked", true); //if user clicks cancel on dialog then do not uncheck the checkbox because it was checked previously
}
});
the problem here is dialog never appears because when the page loads all my div are are visible as i am not able to set the dialogID variable on page load. Also i have atleast 5 dialogs on this page doing same functionality. If you can suggest better approach or tell me what i am doing wrong here would be great and appreciated.
thanks, Milan P