动态更改jQuery UI的对话框按钮文本对话框、按钮、文本、动态

2023-09-10 13:24:46 作者:妓多不压身

我使用jQuery的用户界面对话框,阿贾克斯的形式提交。我想改变的文字我 保存按钮等,当用户点击它,返回保存在Ajax调用完成。 PLS 帮我

I am using jQuery UI Dialog box for ajax form submit. I want change the text of my save button to wait , when user click on it and back to Save when ajax call complete. pls help me

推荐答案

你使用.dialog()方法是通过按钮选择presuming,你可以指定一个自定义类的提交按钮,然后瞄准内通过分配给该跨度类按钮文本(UI按钮文本):

Presuming you're using .dialog() with the buttons option, you can assign a custom class to the submit button, and then target the inner button text via the class that is assigned to the span (ui-button-text):

    $("#dialog-test").dialog({
        title: "My dialog",
        buttons:
            [
              {
                  text: "Submit",
                  click: function() {
                    $(".my-custom-button-class > .ui-button-text").text("Please Wait..."); 
                    $("#some-form").submit();
                  },
                  'class': 'my-custom-button-class'
              }
            ]
    });

当您保存通过提交(完成),您可以使用相同的调用文本重新设置为你想要的。

When your save completes via the submit(), you could use the same call to set the text back to what you want.