Skip to content

Instantly share code, notes, and snippets.

@tsubik
Created October 7, 2012 21:37
Show Gist options
  • Save tsubik/3849685 to your computer and use it in GitHub Desktop.
Save tsubik/3849685 to your computer and use it in GitHub Desktop.
Simple jQueryUI DialogManager
;(function(w){
var DialogManager = (function(){
function DialogManager(){
this.dialogIdx= 1;
};
DialogManager.prototype.createDialog = function(options){
var defaults = {
modal: true,
resizeable: false,
autoOpen: false,
//removing dialog after close
close: function () {
$(this).remove();
}
};
var id = 'dialogId' + this.dialogIdx;
$box = $('#' + id);
if (!$box.length) {
$box = $('<div id="' + id + '"></div>').hide().appendTo('body');
this.dialogIdx++;
}
$box.dialog($.extend({}, defaults, options));
return $box;
};
return DialogManager;
})();
w.DialogManager = new DialogManager;
})(window);
var dialog = DialogManager.createDialog({minWidth: 400, title: 'Set some title'});
dialog.html('Here is the content');
dialog.dialog('open');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment