Created
April 27, 2012 16:55
-
-
Save dongilbert/2510783 to your computer and use it in GitHub Desktop.
Joomla Request Confirmation Before Closing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This goes at the top of your plugin edit view, | |
* and will ask for confirmation before you leave. | |
* Be sure to replace viewname with your controller | |
* name, shortened. If you follow 2.5 guidelines | |
* with sub controllers that handel specific parts | |
* of the application, then this will work fine. | |
*/ | |
Joomla.submitbutton = function(task) { | |
var confirmation = true; | |
var viewname = <?php echo JRequest::get('view'); ?>; | |
if(task === viewname + '.cancel') | |
{ | |
var confirmation = confirm('Have changes to save? Click Cancel, and then Save. Otherwise, click ok.'); | |
} | |
if(confirmation) | |
{ | |
if (task == viewname + '.cancel' || document.formvalidator.isValid(document.id(viewname + '-form'))) { | |
Joomla.submitform(task, document.getElementById(viewname + '-form')); | |
} | |
else { | |
alert('<?php echo $this->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED'));?>'); | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment