Commit 735a635a by tasawernawaz Committed by Tasawer Nawaz

Javascript updated for instructor autocomplete

ECOM-7186
parent b6188232
...@@ -94,6 +94,7 @@ $(document).ready(function(){ ...@@ -94,6 +94,7 @@ $(document).ready(function(){
$('#blog').val(''); $('#blog').val('');
clearModalError(); clearModalError();
closeModal(e, $('#addInstructorModal')); closeModal(e, $('#addInstructorModal'));
loadInstructor(response['uuid'])
}, },
error: function (response) { error: function (response) {
addModalError(gettext("Something went wrong!")); addModalError(gettext("Something went wrong!"));
...@@ -369,3 +370,32 @@ $(document).on('click', '.btn-edit-preview-url', function (e) { ...@@ -369,3 +370,32 @@ $(document).on('click', '.btn-edit-preview-url', function (e) {
$('.btn-preview-decline').click(function(e){ $('.btn-preview-decline').click(function(e){
$('#decline-comment').toggle(); $('#decline-comment').toggle();
}); });
function loadInstructor(uuid) {
var url = $('#id_staff').attr('data-autocomplete-light-url') + '?q=' + uuid,
instructor,
id,
label,
image_source,
name;
$.getJSON({
url: url,
success: function (data) {
if (data['results'].length) {
// with uuid there will be only one instructor
instructor = data['results'][0];
id = instructor.id;
label = $.parseHTML(instructor.text);
image_source = $(label).find('img').attr('src');
name = $(label).find('b').text();
$('#id_staff').append($("<option/>", {
value: id,
text: name
}).attr('selected', 'selected'));
renderSelectedInstructor(id, name, image_source);
}
}
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment