Created
September 25, 2012 14:37
-
-
Save bradrice/3782312 to your computer and use it in GitHub Desktop.
Select 2 dropdown
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]}); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment