|
|
|
define("core/form-cohort-selector",["core/ajax","jquery"],(function(ajax,$){return{processResults:function(selector,data){var results=[],i=0,excludelist=String($(selector).data("exclude")).split(",");for(i=0;i<data.cohorts.length;i++)-1===excludelist.indexOf(String(data.cohorts[i].id))&&results.push({value:data.cohorts[i].id,label:data.cohorts[i].name});return results},transport:function(selector,query,success,failure){var promises;void 0===query&&(query="");var calls=[{methodname:"core_cohort_search_cohorts",args:{query:query,includes:"parents",limitfrom:0,limitnum:100,context:{contextid:$(selector).data("contextid")}}}];promises=ajax.call(calls),$.when.apply($.when,promises).done((function(data){success(data)})).fail(failure)}}}));
|