Jquery UI模态匿名函数回调打开对话框

时间:2013-10-15 11:10:51

标签: javascript jquery jquery-ui

我正在尝试创建一个类似函数(url,class)的函数来创建模态,在页面中加载然后显示它。但是这个函数是从SignalR集线器中方法名称的反映中动态调用的,每次打开所有模态时,我需要能够传入一个div ID唯一,只打开在该实例中创建的模态,我花了一段时间在这上面,但有以下但无法让它工作......请帮助!!!!

我认为它需要进行某种匿名回调,我也用eval()搞砸了无效,想法?

所以modalGo('/ x.html','divid')

只会为特定变量div创建一个模态打开?

function modalGo(url,x) {
var $dialog = $('<div id ="' + x + '></div>').load(url).dialog({
autoOpen: false,
modal: true,
height: 625,
width: 500,
title: "",
zIndex: 190000
}, function() {
$(document.getElementById(x)).dialog('open');
});
}

1 个答案:

答案 0 :(得分:1)

我认为你必须附加div对话框

http://jsfiddle.net/NdN2L/

$(function(){


function modalGo(url,x) {
var dialog = $('<div>Ciao compa</div>');
$('#bibi').append(dialog);
dialog.dialog({
autoOpen: true,
modal: true,
height: 625,
width: 500,
title: "",
zIndex: 190000
}).show();
}

modalGo('http://www.pippo.com','test');

});