Solved

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

Posted on 2013-06-17
2
374 Views
Last Modified: 2013-06-17
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
Comment
Question by:GenericCog
  • 2
2 Comments
 

Author Comment

by:GenericCog
ID: 39254586
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
 

Accepted Solution

by:
GenericCog earned 0 total points
ID: 39254659
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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question