对话框加载时更改我的jquery对话框按钮文本 [英] Changing my jquery dialog button text when dialog loads

查看:81
本文介绍了对话框加载时更改我的jquery对话框按钮文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个像这样的普通jquery对话框:

I have an ordinary jquery dialog like this:

<div id="dialog-confirm" title="Empty the recycle bin?">
   <p>These items will be permanently deleted and cannot be recovered. Are you sure?</p>
</div>

<script>
    $(function(){
        $('#dialog-confirm').dialog({
            resizable: false,
            height: 140,
            modal: true,
            buttons:
                {
                    "Delete all items": function() { $(this).dialog('close'); },
                    "Cancel": function() { $(this).dialog('close'); }
                }
        });
    })
</script>

有时我需要更改文本按钮(例如,如果用户语言为法语).在这种情况下,当加载了jquery对话框时,我想调整按钮.有可能吗?

Sometimes I need to change the text buttons (if user language is french for example). In this case, when the jquery dialog is loaded I would like to adjust buttons. Is it possible?

谢谢

推荐答案

执行此方法以动态翻译按钮文本:-

Do this way for translation of button text dynamically:-

dynamicBtnHandler("Supprimer tous les éléments", "Cancel");

function dynamicBtnHandler(btn1, btn2)
{
    var btnNames = {};
    btnNames[btn1] = function(){ $(this).dialog('close'); };
    btnNames[btn2] = function(){ $(this).dialog('close'); };
    $(function(){

        $('#dialog-confirm').dialog({
            resizable: false,
            height: 140,
            modal: true,
            buttons: btnNames
        });
    })
}

请参阅我的 实时演示

Refer my LIVE DEMO

这篇关于对话框加载时更改我的jquery对话框按钮文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆