Solved

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

Posted on 2013-06-17
2
385 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Report: Liquid Web beats Amazon, Rackspace & More

A study by performance analyst firm Cloud Spectator finds that Liquid Web beats rivals Amazon, Rackspace and DigitalOcean when it comes to website and cloud application performance.

Question has a verified solution.

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

Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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)

752 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