You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.1 KiB
34 lines
1.1 KiB
const event_outcome = (function ($, window, jQuery) {
|
|
return {
|
|
"add_learning": function(learning) {
|
|
$('#learning_outcome').append(`<li>${learning} <i class="fa fa-times-circle remove_learning"></i> </li>`)
|
|
$('#apprendre').val('')
|
|
},
|
|
"format_learning": function () {
|
|
let formattedLearning = []
|
|
const trCount = $('#learning_outcome li')
|
|
if(trCount.length>0) {
|
|
for(let i=0; i<trCount.length; i++) {
|
|
formattedLearning.push($(trCount[i]).text())
|
|
}
|
|
}
|
|
return JSON.stringify(formattedLearning)
|
|
}
|
|
}
|
|
|
|
})(jQuery, this)
|
|
|
|
$(document).ready(function() {
|
|
$('#add_learning').on('click', function() {
|
|
let learningInput = $('#apprendre')
|
|
if(learningInput.val() === '') {
|
|
learningInput.focus()
|
|
} else {
|
|
event_outcome.add_learning(learningInput.val())
|
|
}
|
|
})
|
|
|
|
$('#learning_outcome').on('click', '.remove_learning', function () {
|
|
$(this).closest('li').remove();
|
|
});
|
|
})
|