简体   繁体   English

JavaScript中的自定义消息框

[英]Custom message box in JavaScript

Im looking at making a custom message box in JavaScript but am wondering how I go about doing it. 我正在用JavaScript创建一个自定义消息框,但想知道如何去做。 I have this code below which shows a Yes, No, Cancel message Box: 我在下面的代码中显示了是,否,取消消息框:

 msls.showMessageBox("Please choose the appropriate button", {
            title: "This is a message box",

            buttons: msls.MessageBoxButtons.yesNoCancel

        }).then(function(result) {

            if (result === msls.MessageBoxResult.yes) {

                alert("You have selected Morning");

            } else if (result === msls.MessageBoxResult.no) {

                alert("You Have Selected Afternoon");

            } else if (result === msls.MessageBoxResult.cancel) {

                alert("You have closed this message box");

            }

        });
}

my goal is to rename the button text but im not sure how to do it, here is an example of what I mean: 我的目标是重命名按钮文本,但我不确定该怎么做,这是我的意思的示例:

  • Yes to be Morning 的要早上
  • No to be Afternoon 没有 下午
  • cancel to be cancel 取消 取消

I know how to change what each button does, its just the small part of editing the text inside the button to say what i want, thanks for any help 我知道如何更改每个按钮的功能,这只是编辑按钮内文本以表达我想要的一小部分,谢谢您的帮助

im using Lightswitch HTML and the message box is referenced in jquery.mobile.structure-1.3.0.css file 我使用Lightswitch HTML并在jquery.mobile.structure-1.3.0.css文件中引用了消息框 在此处输入图片说明

You cannot change the text of the buttons if you are using the msls.ShowMessageBox API. 如果使用msls.ShowMessageBox API,则不能更改按钮的文本。 The recommended approach in LightSwitch would be to use a Popup. 在LightSwitch中推荐的方法是使用弹出窗口。

Creating a Popup Screen in LightSwitch 在LightSwitch中创建弹出屏幕

to further add to the above answer, this is how it is done: 进一步添加到上面的答案,这是如何完成的:

create a button on screen, then add this in the execute code: 在屏幕上创建一个按钮,然后将其添加到执行代码中:

if (screen.Table.Variable == true) {
    screen.showPopup("PopupTest");
    } else {
myapp.commitChanges();

from this code you can then add multiple popups with an unknown amount of variables or in my case buttons, each button can be coded to do a certain task. 通过此代码,您可以添加多个带有未知数量变量的弹出窗口,或者在我的情况下,可以将每个按钮编码为执行特定任务。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM