// update Meeting $('body').on('click', '.update_meet', function (e) { e.preventDefault(); attendees_array = []; attendees_type_array = []; var each_filter = '0'; $("#value_drop").select2().removeClass('validate'); var url = $('#add_meet').attr('action'); $(".each_filter").each(function (index) { var attendees_uuid = $(this).attr('data-selected_val'); attendees_array.push(attendees_uuid) $("#value_drop").select2().removeClass('validate'); each_filter = '1'; }) $(".each_filter").each(function (index) { var attendees_type = $(this).attr('data_user_type'); attendees_type_array.push(attendees_type) each_filter = '1'; $("#value_drop").select2().removeClass('validate'); }) // if(each_filter=='0'){ // $( "#value_drop").select2().addClass('validate'); // } var formData = new FormData(document.getElementById("add_meet")); formData.append("attendees", attendees_array); formData.append("attendees_type_array", attendees_type_array); var flag = '0'; $('#add_meet *').filter(':input, textarea, select').each(function () { if ($(this).hasClass('validate')) { if ($(this).val() == '' || $(this).val() == null) { $(this).addClass('error_custom'); $(this).parent().find('.select2-container .select2-selection').addClass( 'error_custom'); flag = '1'; msg = "There are errors on the page" } else { $(this).removeClass('error_custom'); $(this).parent().find('.select2-container .select2-selection').removeClass( 'error_custom'); } } else { $(this).removeClass('error_custom'); $(this).parent().find('.select2-container .select2-selection').removeClass( 'error_custom'); } }); if (flag == '1') { alertbox('danger', 'There are errors on page'); return false; } else { $.ajax({ url: url, type: 'POST', data: formData, processData: false, // tell jQuery not to process the data contentType: false, // tell jQuery not to set contentType success: function (response) { console.log(response); attendees_array = []; attendees_type_array = []; if (response.status == 1000) { $("#new_MeetingAdd").modal("hide"); alertbox('success', response.message) $('#busyloading').hide(); location.reload(); } else if (response.status == 2000) { alertbox('danger', response.message) $('#busyloading').hide(); return false; } else if (response.status == 3000) { alertbox('danger', response.message) $('#busyloading').hide(); return false; } }, error: function (response) { $('#busyloading').hide(); var errors = jQuery.parseJSON(response.responseText); $.each(errors, function (key, val) { $("#" + key + '_error').html(val).show(); }); alertbox('danger', 'There are errors on page'); $('#busyloading').hide(); // location.reload(); } }); } }); // Save Meeting $('body').on('click', '.save_meet', function (e) { e.preventDefault(); $('#busyloading').hide(); attendees_array = []; attendees_type_array = []; var each_filter = '0'; $("#value_drop").select2().removeClass('validate'); var url = $('#add_meet').attr('action'); $(".each_filter").each(function (index) { var attendees_uuid = $(this).attr('data-selected_val'); attendees_array.push(attendees_uuid) each_filter = '1'; $("#value_drop").select2().removeClass('validate'); }) $(".each_filter").each(function (index) { var attendees_type = $(this).attr('data_user_type'); attendees_type_array.push(attendees_type) each_filter = '1'; $("#value_drop").select2().removeClass('validate'); }) var formData = new FormData(document.getElementById("add_meet")); formData.append("attendees", attendees_array); formData.append("attendees_type_array", attendees_type_array); var flag = '0'; $('#add_meet *').filter(':input, textarea, select').each(function () { if ($(this).hasClass('validate')) { if ($(this).val() == '') { $(this).addClass('error_custom'); $(this).parent().find('.select2-container .select2-selection').addClass( 'error_custom'); flag = '1'; } else { $(this).removeClass('error_custom'); $(this).parent().find('.select2-container .select2-selection').removeClass( 'error_custom'); } } }); if (attendees_array.length == 0) { flag = '1'; msg = "There are errors on the page"; $('.option_filters').parent().find('.select2-container .select2-selection').addClass( 'error_custom'); } else { $('.option_filters').parent().find('.select2-container .select2-selection').removeClass( 'error_custom'); flag = '0'; }; if (flag == '1') { alertbox('danger', 'There are errors on page'); return false; } else { $.ajax({ url: url, type: 'POST', data: formData, processData: false, // tell jQuery not to process the data contentType: false, // tell jQuery not to set contentType success: function (response) { attendees_array = []; attendees_type_array = []; if (response.status == 1000) { $("#new_MeetingAdd").modal("hide"); alertbox('success', response.message) $('#busyloading').hide(); location.reload(); } else if (response.status == 2000) { alertbox('danger', response.message) $('#busyloading').hide(); return false; } else if (response.status == 3000) { alertbox('danger', response.message) $('#busyloading').hide(); return false; } }, error: function (response) { var errors = jQuery.parseJSON(response.responseText); $.each(errors, function (key, val) { $("#" + key + '_error').html(val).show(); }); alertbox('danger','There are errors on page'); $('#busyloading').hide(); } }); } });