$(document).ready(function() {
// top nav bar
$('#importbrand').addClass('active');
// manage product data table
$("#brandfile").fileinput({
overwriteInitial: true,
maxFileSize: 2500,
showClose: false,
showCaption: false,
browseLabel: '',
removeLabel: '',
browseIcon: '',
removeIcon: '',
removeTitle: 'Cancel or reset changes',
elErrorContainer: '#kv-avatar-errors-1',
msgErrorClass: 'alert alert-block alert-danger',
layoutTemplates: {main2: '{preview} {remove} {browse}'},
defaultPreviewContent: '
',
allowedFileExtensions: ["csv", "xls", "xlsx"]
});
$(".text-danger").remove();
// remove from-group error
$(".form-group").removeClass('has-error').removeClass('has-success');
// submit product form
$("#submitImportForm").unbind('submit').bind('submit', function() {
// form validation
$(".text-danger").remove();
var brandfile = $("#brandfile").val();
if(brandfile == "") {
$("#brandfile").closest('.center-block').after('
Brand file field is required
'); $('#brandfile').closest('.form-group').addClass('has-error'); } else { // remov error text field $("#brandfile").find('.text-danger').remove(); // success out for form $("#brandfile").closest('.form-group').addClass('has-success'); } // /else if(brandfile) { // submit loading button $("#importBrandBtn").button('loading'); var form = $(this); var formData = new FormData(this); $.ajax({ url : form.attr('action'), type: form.attr('method'), data: formData, dataType: 'json', cache: false, contentType: false, processData: false, success:function(response) { if(response.success == true) { // submit loading button $("#importBrandBtn").button('reset'); $("#submitImportForm")[0].reset(); $("html, body, div.modal, div.modal-content, div.modal-body").animate({scrollTop: '0'}, 100); // shows a successful message after operation $('#add-product-messages').html('