Solved

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

Posted on 2013-06-17
2
365 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
The viewer will learn how to dynamically set the form action using jQuery.
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)

805 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