Joomla custom toolbar button message

删除回忆录丶 提交于 2019-12-08 04:55:20

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!