Helper Functions - jQuery

jQuery UI Helper Functions

/*===============================================================================================*/
function initTogglePanel(selector) {

    $(selector)
        .addClass("ui-accordion ui-accordion-icons ui-widget ui-helper-reset")
        .find("h3")
        .addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-top ui-corner-bottom")
        .hover(function () { $(this).toggleClass("ui-state-hover"); })
        .prepend('<span class="ui-icon ui-icon-triangle-1-e"></span>')
        .click(function () {
            $(this)
                .toggleClass("ui-accordion-header-active ui-state-active ui-state-default ui-corner-bottom")
                .find("> .ui-icon").toggleClass("ui-icon-triangle-1-e ui-icon-triangle-1-s").end()
                .next().toggleClass("ui-accordion-content-active").slideToggle();
            return false;
        })
        .next()
        .addClass("ui-accordion-content  ui-helper-reset ui-widget-content ui-corner-bottom")
        .hide();

}
/*===============================================================================================*/
function initTabsPanel(selector) {
    $(selector).tabs();
}
/*===============================================================================================*/
function initDatePicker(selector, maxIsToday) {

    $(selector).datepicker({
        width: 225,
        height: 150,
        showButtonPanel: true,
        showOtherMonths: true,
        selectOtherMonths: true,
        showAnim: "fadeIn"
    });

    if (maxIsToday == true)
        $(selector).datepicker("option", "maxDate", new Date());
}
/*===============================================================================================*/
function showModalDialog(selector, width, height) {
    $(selector).dialog({
        width: width,
        height: height,
        modal: true,
        /*dialogClass: "divCreateShiftReport",*/
        position: "center",
        hide: "fadeOut",
        show: "fadeIn"
    });
}
/*===============================================================================================*/
function initYoxView(selector) {
    $(selector).yoxview({
        backgroundColor: 'Blue',
        playDelay: 5000
    });

}
/*===============================================================================================*/

Applying Alternating Classes to Table Rows

$.each($('#uxTable tbody tr'), function (rowNum) {
    $(this).addClass(rowNum % 2 == 0 ? 'even' : 'odd');
});   /* each */

Reloading a Page Element via AJAX

/*===========================================================================================*/
function ajaxReloadElement(url, data, targetSelector, httpMethod) {

    if (httpMethod == undefined || httpMethod == null) {
        httpMethod = 'GET';
    }

    $.ajax({
        type: httpMethod,
        url: url,
        async: false,
        datatype: 'json',
        data: data,
        success: function (response) {

            $(targetSelector).html(response);

        } /* success */
    });   /* ajax */
}