如何在JQueryUI模式对话框上本地化按钮 [英] How to localise buttons on JQueryUI modal dialog

查看:81
本文介绍了如何在JQueryUI模式对话框上本地化按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JQueryUI模态对话框,除一个问题外,其他所有东西都工作正常……如何定位确定"和取消"按钮?我已经浏览了演示和文档,除非我遗漏了一些非常明显的内容,否则不知道该怎么做...

I have a JQueryUI modal dialog and everything is working fine except for one issue ... how do I localize the OK and Cancel buttons? I have gone through the demos and documentation and unless I am missing something very obvious, can't figure out how to do this ...

我的代码:

$("#MyDialog").dialog({
.
.
.
    buttons: {
        OK: function () {
.
.
.

        },
        Cancel: function () {
.
.
.
        }
    }
});

这将显示一个带有两个按钮的对话框,分别是确定"和取消".我如何获得要读取的按钮,例如"Si"和"Cancellare" ..?

This displays a dialog with two buttons, "OK" and "Cancel". How do I get the buttons to read, for example, "Si" and "Cancellare" ..?

我需要做的是能够注入一个本地化的值.因此,我不需要将"Si"或"Cancellare"硬编码到对话框设置代码中,而是能够将确定"按钮设置为显示"OK"或"Si"或任何其他值,具体取决于客户的机器.

What I need to do, is to be able to INJECT a localized value. So what I need is not to hard-code "Si" or "Cancellare" into the dialog setup code but to be able to set the OK button to display either "OK" or "Si" or any other value depending on the locale of the client's machine.

关于对话框的其他所有内容都可以正常工作.

Everything else about the dialog works fine.

推荐答案

您只需更改属性的名称...

You just change the name of the property...

var buttons = {};
buttons[getLocalizedCaptionForYesButton()] = function() { };
buttons[getLocalizedCaptionForCancelButton()] = function() { };

$("#MyDialog").dialog({
    buttons: buttons
});

这篇关于如何在JQueryUI模式对话框上本地化按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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