jQuery UI对话框,如何打开对话框后如何更改文本 [英] jQuery UI Dialog, How to change text once the dialog is opened

查看:126
本文介绍了jQuery UI对话框,如何打开对话框后如何更改文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在对话框中单击一个按钮,并在运行与该按钮相关联的功能之前更改消息区域上的文本,或者简单地将文本作为功能的一部分进行更改。

I'd like to click a button in a dialog and change the text on the message area before running the function associated with the button or simply change the text as part of the function.

推荐答案

只需将一个文本区域放入对话框中即可编辑。如果要切换是否可以编辑,只需添加一个按钮。

Just put a text area into the dialog, it will be editable. If you want to toggle whether or not you can edit it just add a button.

(function ($) {
    var $dialog = $('<div></div>')
                    .html('<textarea id="myContent" rows=7 cols=25>Edit me</textarea>')
                    .dialog({
                        autoOpen: false,
                        title: 'editable dialog',
                        buttons: {
                            "Edit": function () { $("#myContent").attr("disabled", !$("#myContent").attr("disabled")); }
                        },
                        height: "auto",
                        width: "auto"
                    });

    $('.dlog').click(function () {
        $dialog.dialog('open');
        return false;
    });
})(jQuery);

这篇关于jQuery UI对话框,如何打开对话框后如何更改文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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