Extend jQuery UI Dialog open function
Is it possible to extend the "open" callback function for the jQuery UI dialog? For example, I am extending my modalDialog box with another called confirmDialog. When opening the modalDialog dialog, I am running a couple of functions that I want to carry over to the confirmDialog but also add another function with it. Here is the code:
// Default settings for the modal dialog
moDefaults : {
autoOpen: 'false',
modal: true,
draggable: false,
resizable: false,
buttons: {},
title: 'Title',
width: 'auto',
ope开发者_开发百科n: function(getDataOnOpen){
// Add open class
jQuery(this).addClass('open_dialog');
// Add classes to action button
var buttonPane = jQuery(this).next();
jQuery(buttonPane).find('button:first').addClass('accept').addClass('action');
// Hide the default dialog close button
jQuery('.ui-dialog-titlebar-close').hide();
// IE hack
jQuery(this).css('overflow','hidden');
// Ajax call to make on open
getDataOnOpen;
},
close: function(){
// Remove open class
jQuery('.ui-dialog').removeClass('open_dialog');
}
},
modalDialog : function(options, dialogId){
if(options){
jQuery.extend(true, mw.moDefaults, options);
}
jQuery(dialogId).dialog(mw.moDefaults);
},
confirmDialog : function(options){
var defaults = {
dialogClass:'confirm_dialog',
minWidth: 255,
modal: true
};
var settings = $.extend(mw.moDefaults, defaults, options);
$.extend(mw.modalDialog(settings,'#conf_dialog'));
}
Thanks in advance SO!!
精彩评论