const event_similar = (function ($, window, jQuery) {
return {
'get_similar_workshops': function(category = 0) {
$('#similar-event-container').empty()
const event_id = events.get_vars().event_id
let similar_events = $('')
$.ajax({
url: app.get_vars().baseurl+"similar_events?category="+category+"&event_id="+event_id,
type: "get",
success: function( result ){
if(result.mtype == "success"){
const options = result.mdata;
for(let i=0; i', {
value: options[i].event_id,
text : options[i].title+' ['+options[i].workshop_author+']'
}))
}
$("#similar-event-container").append(similar_events);
$('#similar-field').multiselect({
enableFiltering: true,
filterPlaceholder: 'Type to search event ...',
maxHeight: 430
});
const similars = events.get_vars().similars
if(similars) {
$('#similar-field option').each((index, element) =>{
if(similars.indexOf(element.value) > -1) {
const x = $("input.form-check-input[value='"+element.value+"']");
x.closest($('button.multiselect-option')).click()
}
});
}
}
}
});
}
}
})(jQuery, this);
$(document).ready(function() {
event_similar.get_similar_workshops(0)
//Enable this code to filter the similar workshop by category
// $('#event_type_id').on('change', function() {
// event_similar.get_similar_workshops(this.value)
// });
});