Skip to content

Instantly share code, notes, and snippets.

@joerixaop
Forked from spint/application.js
Created September 4, 2011 21:53
Show Gist options
  • Save joerixaop/1193569 to your computer and use it in GitHub Desktop.
Save joerixaop/1193569 to your computer and use it in GitHub Desktop.
Build up jQuery-UI dialogs on the fly
// Creates a jQuery UI dialog on the fly, every time a link .user-link is clicked,
// dialog content will be loaded from the url specified by the clicked link
$(function(){
$(".user-link").live('click', function(){
var link = $(this);
$("<div><img src='" + BASEPATH + "images/small-spinner.gif' /> </div>")
.dialog({
autoOpen: true, //for info, true is default
modal: true,
title: 'Apps used by ' + link.attr('data-name'),
width: '720',
minHeight: '400',
open: function(){
$(this).load(link.attr('href'));
},
close: function(){
$(this).dialog('destroy');
$(this).remove();
}
});
return false;
});
}
@joerixaop
Copy link
Author

Reason for remove: dialog('destroy') only removes the dialog surroundings, but leaves the div in the DOM, which may be problematic if there are elements with an ID in the HTML that need to be unique when another dialog is opened

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment