在ajax请求之后初始化的Jquery UI对话框

时间:2011-08-22 21:35:02

标签: php jquery ajax post

我在jQuery UI方面遇到了一些问题。

当我通过ajax重新加载内容时,该功能不起作用。

    dialog: function(mod, url, params) {
    var me = this;

    if (url) {
        game.ajax(url,function(resp, title) { 

            var darea = $('#dialog-ui-content-'+mod);

            if (darea.length > 0) {
                darea.remove();
            }

            $('body').append('<div id="dialog-ui-content-'+mod+'" title="'+title+'">'+resp+'</div>');

            if (!params) params = {};

            if (me.dialogStack[mod]) {
                params = me.dialogStack[mod];
            }

            if (me.dialogStack[url]) {
                params = me.dialogStack[url];
            }

            params.show = 'fade';

            $('#dialog-ui-content-'+mod).dialog(params);
        });
    }
},

功能,重新加载内容:

     ajax: function(url, callback, selector) {
    $.ajax({
         url: url,
         method: 'POST',
         success: function(resp){

            var title_ex = resp.match(/.*<title>(.*?)<\/title>.*/ig); // uses title
            resp = resp.replace(/.*<title>(.*?)<\/title>.*/ig, ""); //
            if (title_ex) {
                title_ex = title_ex.toString().replace(/.*<title>(.*?)<\/title>.*/ig, "$1"); //
            } else {
                title_ex = '';
            }

            if (selector) {
                $(selector).html(resp);
            }

            callback(resp, title_ex);
        },  
        error: function() {
             alert('Could not connect');
         }
    });
},

Google Chorme说:

137Uncaught TypeError: Object [object Object] has no method 'dialog'
(anonymous function)game.js:137
$.ajax.successgame.js:104
f.extend._Deferred.e.resolveWith:16
w:18
f.support.ajax.f.ajaxTransport.send.d

已更新:如果制作一个功能,则会出现同样的问题。

0 个答案:

没有答案