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.
47 lines
2.2 KiB
47 lines
2.2 KiB
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 = $('<select class="form-control" id="similar-field" name="similar-field" multiple="multiple"></select>')
|
|
$.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<options.length; i++) {
|
|
similar_events.append($('<option>', {
|
|
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)
|
|
// });
|
|
});
|