Page 1 of 1

Prevent close modal dialog

Posted: Sun Oct 09, 2016 7:46 am
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.


Re: Prevent close modal dialog

Posted: Sun Oct 09, 2016 2:06 pm
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".


Re: Prevent close modal dialog

Posted: Tue Oct 11, 2016 7:58 am
by belajar

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


Re: Prevent close modal dialog

Posted: Mon Nov 20, 2017 1:46 pm
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.


Re: Prevent close modal dialog

Posted: Sat Dec 09, 2017 8:11 pm
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.


Re: Prevent close modal dialog

Posted: Mon Oct 07, 2019 9:45 am
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");
});


Re: Prevent close modal dialog

Posted: Mon Oct 07, 2019 11:53 pm
by sticcino

yes, thanks, just saw this today.
implemented.