Jquery ui - making dialogs more "dynamic"?

I have a page that uses several dialogs for different things. Some dialogs may have buttons that others do not, while others may require a different height than another ... All of them have a set of parameters that will not change. My question is, can I use by default:

$('.someElement').dialog({
   width: 999,
   show: 'slide',
   hide: 'slide',
   ETC: 'some other option' 
}); 

and use it for all my dialogs, then skip buttons or height dynamically when I open a dialog? It seems wrong to have something like the above for every dialog I need ...

Thank!

+3
source share
2 answers

"option" ( ), :

$('.someElement').dialog({
   width: 999,
   show: 'slide',
   hide: 'slide',
   autoOpen: false
}); 
$('.someElement').dialog('option', {
  buttons: { "Ok": function() { $(this).dialog("close"); } },
  height: 400
}).dialog('open');

, , , open .

+1

-:

function showDialog(target, options){
   options.width = 999;
   options.show = 'slide';
   options.hide = 'slide';

   $(target).dialog(options);
}

, . jQuery, ...

+5

Source: https://habr.com/ru/post/1750546/


All Articles