jeudi 20 juillet 2017

Dropzone not loading on AJAX

I have an environment where I have two forms on one page. One of them is loaded via an AJAX request and the other one exists on page load.

Now, both of them have a dropzone. Note that the IDs of the forms and dropzones are different so there is no ID conflict.

I am using Laravel 5.4 if that matters.

test.blade.php

<form id="show-edit-form" name="show-edit-form" class="form-horizontal" role="form" method="post"
      enctype="multipart/form-data" action="">
    
    <input type="hidden" id="location_id" name="location_id" value="">


    <div class="form-group">
        <div class="col-xs-12">
            <div class="dropzone" id="editfiles"></div>
        </div>
    </div>

    <div class="clearfix form-actions">
        <div class="col-md-3 col-md-9">
            <button class="btn btn-success btn-edit-submit" type="submit" id="edit-submit-all">
                <i class="ace-icon fa fa-save fa-fw bigger-110"></i> Save changes
            </button>
        </div>
    </div>

</form>

<div class="form-test">

</div>

javascript

jQuery(function ($) {

    Dropzone.options.editfiles = {
        url: 'laravel route',
        ...
    };

    $(document).on('click', '.btn-test', function () {
        $.ajax({
            url: "my url",
            success: function(data) {
                $('.form-test').html(data); // Form returned here
                Dropzone.options.files = {
                    url: 'another laravel route',
                    ...
                };
            }
        });        
    )};

)};

The problem is that, the other dropzone which is created after an AJAX request is not rendered even though I have specified it.

Some help would be appreciated. Thanks.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2uD5Pel
via IFTTT

Aucun commentaire:

Enregistrer un commentaire