Created
August 8, 2015 21:31
-
-
Save brian-lim-42/e490a926e159b2ae6b84 to your computer and use it in GitHub Desktop.
jQuery UI Open Dialog and Create a Close Button
This file contains hidden or 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
var modalDialog = $('#dialogDiv').dialog({ | |
autoOpen: false, | |
open: function () { | |
// Destroy Close Button (for subsequent opens) | |
$('#dialog-div-close').remove(); | |
// Create the Close Button (this can be a link, an image etc.) | |
var link = '<a id="dialog-div-close" href="#" style="float:right;text-decoration:none;">Close</a>'; | |
// Create Close Button | |
$(this).parent().find(".ui-dialog-titlebar").append(link); | |
// Add close event handler to link | |
$('#dialog-div-close').on('click', function () { | |
modalDialog.dialog('close'); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment