Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 395
  • Last Modified:

How To Put Many $(document).on('click'...) Functions Into Switch Statement?

How do I put all of these into a clean Switch statement?
$(document).on('click', '#container-Home', function () {
    $('#patientName-Home').html(getSelectedPatientName());
    var dialogStyle_Home = { modal: true, width: 725, height: 500, show: captureConfig.defaultDialogShowEffect, hide: captureConfig.defaultDialogHideEffect, draggable: false, resizable: false, closeOnEscape: false };
    $('#modalMain-Home').dialog(dialogStyle_Home, {}).dialog("widget").find(".ui-dialog-titlebar").hide();
});
$(document).on('click', '#container-QuickAdmit', function () {
    $('#patientName-QuickAdmit').html(getSelectedPatientName());
    var dialogStyle_QuickAdmit = { modal: true, width: 725, height: 500, show: captureConfig.defaultDialogShowEffect, hide: captureConfig.defaultDialogHideEffect, draggable: false, resizable: false, closeOnEscape: false };
    $('#modalMain-QuickAdmit').dialog(dialogStyle_QuickAdmit, {}).dialog("widget").find(".ui-dialog-titlebar").hide();
});
$(document).on('click', '#container-Charges', function () {
    $('#patientName-Charges').html(getSelectedPatientName());
    var dialogStyle_Charges = { modal: true, width: 725, height: 500, show: captureConfig.defaultDialogShowEffect, hide: captureConfig.defaultDialogHideEffect, draggable: false, resizable: false, closeOnEscape: false };
    $('#modalMain-Charges').dialog(dialogStyle_Charges, {}).dialog("widget").find(".ui-dialog-titlebar").hide();
});
$(document).on('click', '#container-Assignments', function () {
    $('#patientName-Assignments').html(getSelectedPatientName());
    var dialogStyle_Assignments = { modal: true, width: 725, height: 500, show: captureConfig.defaultDialogShowEffect, hide: captureConfig.defaultDialogHideEffect, draggable: false, resizable: false, closeOnEscape: false };
    $('#modalMain-Assignments').dialog(dialogStyle_Assignments, {}).dialog("widget").find(".ui-dialog-titlebar").hide();
});
$(document).on('click', '#container-Print', function () {
    $('#patientName-Print').html(getSelectedPatientName());
    var dialogStyle_Print = { modal: true, width: 725, height: 500, show: captureConfig.defaultDialogShowEffect, hide: captureConfig.defaultDialogHideEffect, draggable: false, resizable: false, closeOnEscape: false };
    $('#modalMain-Print').dialog(dialogStyle_Print, {}).dialog("widget").find(".ui-dialog-titlebar").hide();
});
$(document).on('click', '#container-Discharge', function ()
{
    setGlobalDischargeValues();
    $('#patientName-Discharge').html(getSelectedPatientName());
    $(".ui-dialog-content").css("padding", 0);
    var dialogStyle_Discharge = { modal: true, width: 725, height: 370, show: captureConfig.defaultDialogShowEffect, hide: captureConfig.defaultDialogHideEffect, draggable: false, resizable: false, closeOnEscape: false };
    $('#modalMain-Discharge').dialog(dialogStyle_Discharge, {}).dialog("widget").find(".ui-dialog-titlebar").hide();
});
$(document).on('click', '#container-StayDelete', function () {
    setGlobalStayDeleteValues();
    $('#patientName-StayDelete').html(getSelectedPatientName());
    var dialogStyle_StayDelete = { dialogSelector:$('#modalMain-StayDelete'), isTitleBarVisible:false, modal: true, width: 725, height: 290, show: captureConfig.defaultDialogShowEffect, hide: captureConfig.defaultDialogHideEffect, draggable: false, resizable: false, closeOnEscape: false };
    showDialog(dialogStyle_StayDelete);
});

Open in new window

0
GenericCog
Asked:
GenericCog
  • 2
1 Solution
 
GenericCogAuthor Commented:
I tried this but it does not work:
$(document).on('click', "#container-Home", "#container-QuickAdmit", "#container-Charges", "#container-Assignments", "#container-Print", "#container-Discharge", "#container-StayDelete", function () {
    switch ($(this).attr('id')) {
        case '#container-Home':
            var dialogStyle_Home = { dialogSelector: pv_OpenDialog, istitlebarvisible: false, modal: true, width: 725, height: 350, show: captureConfig.defaultdialogshoweffect, hide: captureConfig.defaultdialoghideeffect, draggable: false, resizable: false, closeonescape: false };
            showDialog(dialogStyle_Home);
            $('#patientName-Home').html(getSelectedPatientName()); 
            break;
        case '#container-Assignments':
            var dialogStyle_Assignments = { dialogSelector: pv_OpenDialog, istitlebarvisible: false, modal: true, width: 725, height: 350, show: captureConfig.defaultdialogshoweffect, hide: captureConfig.defaultdialoghideeffect, draggable: false, resizable: false, closeonescape: false };
            showDialog(dialogStyle_Assignments);
            $('#patientName-Assignments').html(getSelectedPatientName()); 
            break;
        case '#container-Charges':
            var dialogStyle_Charges = { dialogSelector: pv_OpenDialog, istitlebarvisible: false, modal: true, width: 725, height: 350, show: captureConfig.defaultdialogshoweffect, hide: captureConfig.defaultdialoghideeffect, draggable: false, resizable: false, closeonescape: false };
            showDialog(dialogStyle_Charges);
            $('#patientName-Charges').html(getSelectedPatientName()); 
            break;
        case '#container-QuickAdmit':
            var dialogStyle_QuickAdmit = { dialogSelector: pv_OpenDialog, istitlebarvisible: false, modal: true, width: 725, height: 350, show: captureConfig.defaultdialogshoweffect, hide: captureConfig.defaultdialoghideeffect, draggable: false, resizable: false, closeonescape: false };
            showDialog(dialogStyle_QuickAdmit);
            $('#patientName-QuickAdmit').html(getSelectedPatientName()); 
            break;
        case '#container-Print':
            var dialogStyle_Print = { dialogSelector: pv_OpenDialog, istitlebarvisible: false, modal: true, width: 725, height: 350, show: captureConfig.defaultdialogshoweffect, hide: captureConfig.defaultdialoghideeffect, draggable: false, resizable: false, closeonescape: false };
            showDialog(dialogStyle_Print);
            $('#patientName-Print').html(getSelectedPatientName()); 
            break;
        case '#container-Discharge':
            setGlobalDischargeValues(); // set Discharge values
            var dialogStyle_Discharge = { dialogSelector: pv_OpenDialog, istitlebarvisible: false, modal: true, width: 725, height: 370, show: captureConfig.defaultdialogshoweffect, hide: captureConfig.defaultdialoghideeffect, draggable: false, resizable: false, closeonescape: false };
            showDialog(dialogStyle_Discharge);
            $('#patientName-Discharge').html(getSelectedPatientName()); 
            break;
        case '#container-StayDelete':
            setGlobalStayDeleteValues();    // set StayDelete values
            var dialogStyle_StayDelete = { dialogSelector: pv_OpenDialog, istitlebarvisible: false, modal: true, width: 725, height: 290, show: captureConfig.defaultdialogshoweffect, hide: captureConfig.defaultdialoghideeffect, draggable: false, resizable: false, closeonescape: false };
            showDialog(dialogStyle_StayDelete);
            $('#patientName-StayDelete').html(getSelectedPatientName()); 
            break;
    }
});

Open in new window

0
 
GenericCogAuthor Commented:
Solved it.
$(document).on('click', '#container-Discharge, #container-Home, #container-QuickAdmit, #container-Charges, #container-Assignments, #container-Print, #container-StayDelete', function () {
    switch ($(this).attr('id')) {
        case 'container-Home':
            var dialogStyle_Home = { dialogSelector: $('#modalMain-Home'), isTitleBarVisible: false, modal: true, width: 725, height: 350, show: captureConfig.defaultDialogShowEffect, hide: captureConfig.defaultDialogHideEffect, draggable: false, resizable: false, closeOnEscape: false };
            showDialog(dialogStyle_Home);
            $('#patientName-Home').html(getSelectedPatientName()); 
            break;
        case 'container-Assignments':
            var dialogStyle_Assignments = { dialogSelector: $('#modalMain-Assignments'), isTitleBarVisible: false, modal: true, width: 725, height: 350, show: captureConfig.defaultDialogShowEffect, hide: captureConfig.defaultDialogHideEffect, draggable: false, resizable: false, closeOnEscape: false };
            showDialog(dialogStyle_Assignments);
            $('#patientName-Assignments').html(getSelectedPatientName()); 
            break;
        case 'container-Charges':
            var dialogStyle_Charges = { dialogSelector: $('#modalMain-Charges'), isTitleBarVisible: false, modal: true, width: 725, height: 350, show: captureConfig.defaultDialogShowEffect, hide: captureConfig.defaultDialogHideEffect, draggable: false, resizable: false, closeOnEscape: false };
            showDialog(dialogStyle_Charges);
            $('#patientName-Charges').html(getSelectedPatientName()); 
            break;
        case 'container-QuickAdmit':
            var dialogStyle_QuickAdmit = { dialogSelector: $('#modalMain-QuickAdmit'), isTitleBarVisible: false, modal: true, width: 725, height: 350, show: captureConfig.defaultDialogShowEffect, hide: captureConfig.defaultDialogHideEffect, draggable: false, resizable: false, closeOnEscape: false };
            showDialog(dialogStyle_QuickAdmit);
            $('#patientName-QuickAdmit').html(getSelectedPatientName()); 
            break;
        case 'container-Print':
            var dialogStyle_Print = { dialogSelector: $('#modalMain-Print'), isTitleBarVisible: false, modal: true, width: 725, height: 350, show: captureConfig.defaultDialogShowEffect, hide: captureConfig.defaultDialogHideEffect, draggable: false, resizable: false, closeOnEscape: false };
            showDialog(dialogStyle_Print);
            $('#patientName-Print').html(getSelectedPatientName()); 
            break;
        case 'container-Discharge':
            setGlobalDischargeValues(); // set Discharge values
            var dialogStyle_Discharge = { dialogSelector: $('#modalMain-Discharge'), isTitleBarVisible: false, modal: true, width: 725, height: 370, show: captureConfig.defaultDialogShowEffect, hide: captureConfig.defaultDialogHideEffect, draggable: false, resizable: false, closeOnEscape: false };
            showDialog(dialogStyle_Discharge);
            $('#txtDischargeDate').val(getTodaysDate());
            //$('#txtDischargeDate').datepicker();
            $('#patientName-Discharge').html(getSelectedPatientName()); 
            break;
        case 'container-StayDelete':
            setGlobalStayDeleteValues();    // set StayDelete values
            var dialogStyle_StayDelete = { dialogSelector: $('#modalMain-StayDelete'), isTitleBarVisible: false, modal: true, width: 725, height: 290, show: captureConfig.defaultDialogShowEffect, hide: captureConfig.defaultDialogHideEffect, draggable: false, resizable: false, closeOnEscape: false };
            showDialog(dialogStyle_StayDelete);
            $('#patientName-StayDelete').html(getSelectedPatientName()); 
            break;
    }
});

Open in new window

0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now