Skip to content

Instantly share code, notes, and snippets.

@bradrice
Created September 25, 2012 14:37
Show Gist options
  • Save bradrice/3782312 to your computer and use it in GitHub Desktop.
Save bradrice/3782312 to your computer and use it in GitHub Desktop.
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]});
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment