I am trying to block the background with my two jquery modal dialogs until the user closes the window. Any idea on how to achieve this?
By "blocking the background" I mean disabling the other elements on the page (i.e. making other elements unclickable).
Here is my code below:
// sign up dialog
$( "#aboutus_dialog" ).dialog({
autoOpen: false,
show: "fadein",
hide: "fadeout"
});
// sign up dialog
$( "#signup_dialog" ).dialog({
autoOpen: false,
show: "fadein",
hide: "fadeout"
});
// about us modal
$('#aboutus').click(function() {
modal: true,
$("#aboutus_dialog").dialog("open");
return false;
});
// about us modal
$('#signup').click(function() {
$("#signup_dialog").dialog("open");
return false;
});
});
tab, shift + tab and enter key and focus should be trapped inside modal and should not go out after pressing tab key multiple times.
The key idea is to have pointer-events: none; for the body when modal is open. But the specific elements you want to be interacted with should have e.g. pointer-events: auto; . In the example you can click both buttons when dialog is hidden, but only Toggle Dialog button when dialog is shown.
Using aria-modal="true" replaces the need to add aria-hidden="true" for elements that should be hidden from screen readers and not receive keyboard focus outside the modal while the modal is open.
Definition: A modal dialog is a dialog that appears on top of the main content and moves the system into a special mode requiring user interaction. This dialog disables the main content until the user explicitly interacts with the modal dialog.
Is this what you're looking for
http://jqueryui.com/demos/dialog/#modal
It does block the background you have the view source button. Do you have any overlay at all?
Try setting it manually(not recommended but rather trough css) :
$(".ui-widget-overlay").attr('style','background-color: #000; opacity:1; z-index:1000;');
And of course setting the modal option to true.
If the color is too strong decrease the opacity accordingly.
when i changed modal value to 'true' (in angular js) all background elements got disabled.here is my code attached:
var options = {
autoOpen : false,
modal : true,
close : function(event, ui) {
console.log("Predefined close");
}
};
dialogService.open("myDialog" + k, "dialogTemplateload.html", model, options)
.then(
function(result) {
console.log("Close");
console.log(result);
},
function(error) {
console.log("Cancelled");
}
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With