As I searched through Stackoverflow and Google, I couldn't find a solution to simplifying my code (or maybe I haven't found the exact search term). It really bugs me that I couldn't simplify the code below.
Since I'm a beginner in this field, I had to repeat all the same code all over again, when there are similarities that I can combine.
Your help is much appreciated!
$('.detail-view').dialog({
autoOpen: false,
draggable: false,
resizable: false,
closeOnEscape: true,
modal: true,
height: 'auto',
width: 600,
position: ['top', 150] });
$('.forgotpass').dialog({
autoOpen: false,
draggable: false,
resizable: false,
closeOnEscape: true,
modal: true,
height: 'auto',
width: 400,
position: ['top', 150] });
$('.user0').load('php/usersetting.php').dialog({
autoOpen: true,
draggable: false,
resizable: false,
closeOnEscape: false,
modal: true,
height: 'auto',
width: 500,
position: ['top', 150],
open: function(){
$(this).parent().find('.ui-dialog-titlebar-close').hide();
} });
$('.user1').load('php/usersetting.php').dialog({
autoOpen: false,
draggable: false,
resizable: false,
modal: true,
height: 'auto',
width: 500,
position: ['top', 100] });
$('.user2').load('php/usersetting.php').dialog({
autoOpen: true,
draggable: false,
resizable: false,
closeOnEscape: true,
modal: true,
height: 'auto',
width: 500,
position: ['top', 150],
open: function(){
$(this).parent().find('.ui-dialog-titlebar-close').hide();
}
});
$.extend()to make variations. Also, take advantage of the,in selector syntax to combine separate calls.