bradrice
9/25/2012 - 2:37 PM

Select 2 dropdown

Select 2 dropdown

function build_course_dept_dds(thisCourseCell)
{
    selector = (!thisCourseCell)?$('.thisCourseDept'):$('.thisCourseDept',thisCourseCell);
    //console.log('build_course_dept_dds');
    
    selector.select2(
    {
        data:thisCourseDeptData,
        placeholder: 'Select Department/Track'
    }).bind('change',function(){
        thisCourseCell = $(this).parents('.cellTermYear');
        is_valid_cell_course(thisCourseCell);
    });
    
    // when loading the edit screen, this establised a for the course department dropdowns... only designed loads to fire document onLoad
    if(!thisCourseCell) {
        $('.thisCourseDept.existing').each(function()
        {
            if($(this).attr('startVal')) {
                var startVal = $(this).attr('startVal');
                var deptsObj={};
                var c=arrDepts.length;
                while (c--) {
                    var pair=arrDepts[c];
                    deptsObj[pair[0]]=pair[1];
                };
                $(this).select2("val", {id:startVal, text:deptsObj[startVal]}); 
            }
        });
    }
}