问题
The standard admin toolbar buttons have the possibility that you can give them a message. For example: a "really delete" message or something...
JToolBarHelper::deleteList('Do you wanna really delete?', 'controller.delete');
Is that also possible for a custom button? In the documentation is no parameter for this. http://docs.joomla.org/JToolBarHelper/custom
Did Joomla have another solution? Show the user a message and after his confirmation... execute my code! Is that possible?
Sorry for my bad english :) thanks!
回答1:
Sure it is possible :)
Simply add to your component template view (for example:)
administrator/components/com_yourcomponent/views/your_view/tmpl/default.php
this code:
<script type="text/javascript">
Joomla.submitbutton = function(task)
{
if (task == 'customcontroller.delete')
{
if (confirm(Joomla.JText._('Do you really want to delete these items?'))) {
Joomla.submitform(task);
} else {
return false;
}
}
}
</script>
Just change the task and edit the message and you should be ready to go
回答2:
Add this code to this url : administrator/components/com_yourcomponent/views/your_view/tmpl/default.php
<script type="text/javascript">
Joomla.submitbutton = function(task)
{
if (task == 'customcontroller.delete')
{
if (confirm('Do you really want to delete these items?')== true)
{
Joomla.submitform(task);
}
else {
return false;
}
}
else
{
Joomla.submitform(task);
}
}
</script>
来源:https://stackoverflow.com/questions/21682391/joomla-custom-toolbar-button-message