1

I am using Uploadcare on my site and I am loving it.

I have one problem though I am using a bootstrap modal which I load the data through AJAX. I want Uploadcare widget to recognise that the file already exists and show the picture (not ask to upload new). Is there a way to force the widget to refresh and read the value="". If I set the value before it works as intended.

My code is below: data[4] returns the URL of the Uploadcare image

<input type="hidden"
       id="editurl"
       name="url"
       role="uploadcare-uploader"
       data-crop=""
       data-images-only="true">

$.ajax({
        type: "POST",
        dataType: "json",
        url: "worker.php",
        data: "action=details&id="+ id +"",
        error: function() {
            show_notification("danger", "warning-sign", "Ajax query failed!");
        },
        success: function(data) {
            $("#editurl").val(data[4]);
        }
    });
Dmitry Mukhin
  • 6,649
  • 3
  • 29
  • 31
Josh Fradley
  • 545
  • 1
  • 10
  • 23

1 Answers1

1

You just need the following in success handler:

var widget = uploadcare.Widget('#editurl');
widget.value(data[4]);

More info may be found on JS API documentation page.

Dmitry Mukhin
  • 6,649
  • 3
  • 29
  • 31