Solved

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

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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.Net creating Contact in Outlook 1 47
Get sourcecode path 14 46
ASP get fieds value 2 20
Blending HTML output from R Studio into a ASP.Net/C# project 4 15
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
The viewer will learn how to dynamically set the form action using jQuery.
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…

685 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