Skip to content

Not possible to use backdrop: 'static' in app.helper.js showModal()

See this discussion on the mailing list:

http://lists.vtigercrm.com/pipermail/vtigercrm-developers/2019-October/038288.html

Basically, because when the modal is closed, it's data (options) are not cleared, if it was previously loaded without the backdrop: 'static' option then setting it in your call to showModal() will not work.

In layouts/v7/resources/helper.js adding one line to the hideModel() function, after line 455, which clears the data attributes when modal is hidden with fix the problem...

https://code.vtiger.com/vtiger/vtigercrm/blob/master/layouts/v7/resources/helper.js#L455

e.g.

		$('.myModal').modal('hide'); 
		$('.myModal').data('bs.modal',null); // New line to clear any options previously set

So with this fix in any custom code you are writing you can call the showModal() function with the backdrop: 'static' option and clicking on the background will NOT close the modal.

...
            var params = {
                "cb": callBackFunction,
                backdrop: 'static', // Prevent modal from closing when background area is clicked. (Requires mod to layouts/v7/resources/helper.js too.)
            };
            app.helper.showModal(data, params);