Prevent close modal dialog

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
belajar
User
Posts: 37

Prevent close modal dialog

Post by belajar »

Hello phpmaker expert,
May i ask a question. When i tried new feature modal dialog on add page it work.
But when we click at the gray background. It closed that modal form.
I found useful information that advice to set property of that modal form 'backdrop' : 'static'
Like this:
$('#myModal').modal({
backdrop: 'static', // This disable for click outside event
})
How to implement it to phpmaker project? Thanks.


mobhar
User
Posts: 11726

Post by mobhar »

Not quite sure your code will work properly. However, basically, you may put that code under "Client Scripts" -> "Global" -> "Pages with header/footer" -> "Startup Script".


belajar
User
Posts: 37

Post by belajar »

Thanks. But Im still cant do it work. Maybe i have to learn javascript first.


sangnandar
User
Posts: 980

Post by sangnandar »

This is old topic but I'm experiencing the same problem.

This code:

$(document).ready(function(){
$('#ewModalDialog').on("shown.bs.modal", function() {
$(this).data('bs.modal').options.backdrop = 'static'; // disable mouse click outside modal
$(this).data('bs.modal').options.keyboard = false; // disable ESC key
});
});

1-st line is ok but 2-nd line gives unexpected behavior, it only works on the second++ launch of the modal, don't work on the first launch.
Remove 1-st line, 2-nd line is ok. Vice versa.
So it's probably because backdrop and keyboard options should stick together as an array, fires in one line.
But I don't know, neither how to form the array using this approach, nor do the array method exist for this approach.

Please help.
Thanks.


belajar
User
Posts: 37

Post by belajar »

sorry for very very late respond mr sangnandar.
i had to work for some research project on my campus. hope you understand.

i tried this approach and solved my problem,
go to CLIENT SCRIPT->GLOBAL->PAGES WITH HEADER/FOOTER->STARTUP SCRIPT

document.getElementById("ewModalDialog").setAttribute("data-backdrop", "static");
document.getElementById("ewAddOptDialog").setAttribute("data-backdrop", "static");

hope it will help you too.


mobhar
User
Posts: 11726

Post by mobhar »

For PHPMaker v2020, you may simply put the following code into "Client Scripts" -> "Global" -> "Pages with Header/Footer" -> "Startup Script":

loadjs.ready("load", function() {
document.getElementById("ew-modal-dialog").setAttribute("data-backdrop", "static");
document.getElementById("ew-add-opt-dialog").setAttribute("data-backdrop", "static");
});


sticcino
User
Posts: 1043

Post by sticcino »

yes, thanks, just saw this today.
implemented.


Post Reply