2016-04-12 42 views
1

Nesne. hatta .product_imgfiles tıklandı. Bu maxFiles hala eski değeri kullanır. myDropzone nesnesinin her zaman güncellenmiş değeri nasıl kullanılır .product_imgfiles tıklanır?Bu kodu vardır

cevap

2

myDropzone

$(document).ready(function() { 

    var dropzone_maxfiles = '.$product_maxfiles.'; 

    $(".product_imgfiles").click(function(event) { 
    event.preventDefault(); 
    var img_file = $(this).children("img").attr("src"); 

    $.ajax({ 
     url: "controller/ctrl.dropzonejs-cleaner.php?token='.$product_token.'&key='.$secret_token.'&imgfile=" + img_file + "" 
    }); 

    $(this).parent("div").remove(); 
    dropzone_maxfiles = dropzone_maxfiles + 1; 
    myDropzone.options.maxFiles = dropzone_maxfiles; 

    }); 

    var myDropzone = new Dropzone(".dropzone", { 
    url: "controller/ctrl.dropzonejs.php?token='.$product_token.'&key='.$secret_token.'", 
    maxFilesize: 2, 
    maxFiles: '.$product_maxfiles.', 
    acceptedFiles: ".jpeg, .jpg, .png, .gif" 
    }); 

    myDropzone.on("complete", function() { 
    var rejected = myDropzone.getRejectedFiles(); 

    if (rejected == "") { 
     $(".btn-vendor-addnew").removeClass("disabled"); 
     $(".dropzone-error").css("display", "none"); 
    } else { 
     myDropzone.removeAllFiles(true); 
     $(".btn-vendor-addnew").addClass("disabled"); 
     $(".dropzone-error").css("display", "block"); 

     $.ajax({ 
     url: "controller/ctrl.dropzonejs-cleaner.php?token='.$product_token.'&key='.$secret_token.'" 
     }); 
    } 
    }); 

}); 
+0

WOW seçenek değerini ayarlamak için deneyin !! BU ÇALIŞMALAR, BRO !!! şaşırtıcı !! çok teşekkür ederim... –