jquery对话破坏语法

时间:2015-06-10 16:27:20

标签: javascript jquery ajax jquery-ui asp.net-ajax

我有一个加载部分视图的对话框,从我的MVC 4应用程序中的许多不同视图调用。它有一个文本区域,以及文本区域中剩余字符数的小注意事项。所有在页面加载时都能正常工作,但是当对话框关闭时,无论是通过发送按钮还是对话框标题栏中的关闭按钮,当重新打开时,“#textarea_feedback”div内容将消失,直到页面重新加载。我相信我应该使用对话框('destroy'),但似乎无法正确使用语法。要么它没有效果,要么在页面底部显示部分视图。请指教,希望我已经包含足够的代码来识别问题。感谢名单

var gulp = require('gulp'),
    open = require('gulp-open'),
    browserSync = require('browser-sync').create();

var WebSocketServer, socket, wss;

WebSocketServer = require('ws').Server;

wss = new WebSocketServer({
    port: 9191
});

var reload = browserSync.reload;

var paths = {
    css: 'app/REPSuite/web/static/css/*.css',
    js: 'app/REPSuite/web/static/js/*.js',
    html: 'app/*.html'
};

gulp.task('reload', function() {
    var client, i, len, ref, results;
    ref = wss.clients;
    results = [];
    for (i = 0, len = ref.length; i < len; i++) {
        client = ref[i];
        results.push(client.send('reload'));
    }
    return results;
});

socket = null;

this.reloadClient = {
    connect: function() {
        socket = new WebSocket('wss://localhost:9191');
        socket.onopen = function() {
            return console.log('connected');
        };
        socket.onclose = function() {
            return console.log('closed');
        };
        return socket.onmessage = function(message) {
            if (message.data === "reload") {
                return window.chrome.runtime.reload();
            }
        };
    },
    disconnect: function() {
        return socket.close();
    }
};

// Static Server + watching scss/html files
gulp.task('serve', ['css'], function() {

    browserSync.init({
        server: "./app",
        files: [paths.html, paths.css, paths.js]
    });

    gulp.watch(paths.css, ['css']);
    gulp.watch(paths.html).on('change', browserSync.reload);
});

// Compile sass into CSS & auto-inject into browsers
gulp.task('css', function() {
    return gulp.src(paths.css)
        .pipe(browserSync.stream());
});

gulp.task('default', ['serve','reload']);

1 个答案:

答案 0 :(得分:0)

想要发布答案,以防它可以帮助别人,真的是LShetty的评论引导我朝着正确的方向前进。添加到创建对话框的Ajax调用的CLOSE函数:

    $.ajax({
    url: 
      ...
    type: "POST",
    success: function (responseText, textStatus, XMLHttpRequest) {
        dialog.html(responseText);
        dialog.dialog({
            ...
            title: 'Send message',
            open: function () {
               ...
            },
            close: function () {
                $(this).dialog('destroy').remove()
            },
            ...
        });
    }