Created
September 1, 2011 07:59
-
-
Save spint/1185672 to your computer and use it in GitHub Desktop.
Build up jQuery-UI dialogs on the fly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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'); | |
} | |
}); | |
return false; | |
}); | |
} |
Also, you need to close your img tag at least with a >
And why autoOpen false, followed immediately by open? It's not that it will be reused
$dialog is in this case not necessary indeed.
And yes, it's easier to just let it autoOpen here :-)
gist updated
todo: error handling
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$dialog typo or intended?