Reputation: 370
I'm trying to create a function like function(url,class) to create a modal,load in a page and then display it. however this function is dynamically called from reflection of method names in a SignalR hub, each time it opens up all modals, I need to be able to pass in a div ID unique to open up just the modal created in that instance, I have spent a while on this and have the below but can't get it to work... Please help!!!!
I think it needs to be some kind of anonymous callback, I have also messed about with eval() to no avail, thoughts?
So modalGo('/x.html','divid')
would create a modal open only for the specific variable created 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');
});
}
Upvotes: 0
Views: 871
Reputation: 347
i think you must append the div dialog
$(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');
});
Upvotes: 1