JQuery UI 对话框 - 成功时 Ajax 更新 $(this).dialog ('close' );

标签 jquery user-interface jquery-ui-dialog

在嵌套 ajax“成功”函数中引用 $(this) 时出现问题...我知道这是一个范围问题,但似乎无法找到一种干净的方法来在成功更新时关闭对话框。感谢您的帮助。

$("#dialog_support_option_form").dialog({
        width: 400,
        height: 180,
        bgiframe: true,
        autoOpen: false,
        modal: true,
        buttons: {
            'Save Support Option': function(){
                $.ajax({
                    type: 'POST',
                    url: "support_options/create_support_option.php",
                    data: $(this).find('form').serialize(),
                    success: function(data){
                        $("#list_support_options").html(data);
                        $(this).dialog('close');
                    }
                });
            },
            'Cancel': function(){
                $(this).dialog('close');
            }
        },
        close: function(){
            $(this).find('input').val('');
        }
    });

最佳答案

您应该使用 ajax 选项 context: $(this), 设置所选元素的回调范围。

关于JQuery UI 对话框 - 成功时 Ajax 更新 $(this).dialog ('close' );,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2585756/

相关文章:

javascript - 页面加载时 Jquery Mobile 对话框未加载

javascript - 访问特定url时自动触发点击事件

Java Swing 如何修复 JLabel 大小

javascript - 在 jQueryUI 对话框中显示和格式化数组元素

jquery-ui - jQuery UI 对话框 : vertical scroll works not correct if dialog height more than window height

ajax - jquery - 加载所有文本文件并显示它们

javascript - jQuery if 语句触发两次

git - 在 git 命令行中禁用进度指示

java - 如何将AbstractButton的标签放在Icon的底部?

jquery - 如何使用特定 ID 设置 jQueryUI 对话框标题的样式?