0

我有一个对话框,会在选择某个跨度时弹出。现在此对话框包含一个文本区域(因此可编辑)。单击“保存”按钮时,我需要将 textarea 内容复制到对话框外的表格单元格中。这似乎没有发生。实际上在保存功能中添加第二行代码,对话框不弹出!(在 WordPress 中使用它以防万一它有所作为)

jQuery(document).ready(function ($) {
    $("td > span").click(function () {
        var id = $(this).attr('id');
        var message = "message" + id;
        var content = jQuery("#" + message).text();
        var $dialog = $("<div></div>").html("<textarea style='width:99%; height:90%' class='popup-content'>" + content + "</textarea>").dialog({
            height: 400,
            width: 400,
            title: 'My Data',
            modal: true,
            autoOpen: false,
            dialogClass: 'wp-dialog',
            buttons: {
                "Save": function () {
                    var popup - content = $(".popup-content").val();
                }
            }
        });
        $dialog.dialog("open");
    });
});
4

1 回答 1

0

保存按钮不再起作用,因为var popup - content不是有效的 javascript。如果有能力,我首先建议在您的编辑器中添加一些 JSLint 或 JSHint 功能。

现在,要完成您想要完成的事情,它应该相当简单。我们将忽略一些潜在的地雷,并假设您的类是唯一标识的,但您的保存功能应该如下所示:

function() {
    $(".my-table-cell").html($(".popup-content").val());
}
于 2013-11-09T17:15:39.640 回答