uploadcare-widget icon indicating copy to clipboard operation
uploadcare-widget copied to clipboard

Expose cleanup() method

Open fabien opened this issue 8 years ago • 5 comments

Currently, there is no way to cleanly destroy a Widget from the DOM, which is critical in SPA setups.

The functionality exists, however, in the form of a cleanup() method:

https://github.com/uploadcare/uploadcare-bower/blob/master/uploadcare.js#L8075

But since it's wrapped in a closure, it is not publicly exposed. I think there should be a destroy method on a Widget instance to handle this properly.

fabien avatar Mar 31 '16 12:03 fabien

I think you are right, we need such method in the API. But I don't satisfied with the cleanup quality (for example, it selects .next('.uploadcare-widget') while it can be not exactly widget element). So It's a bit complex than just expose already existing method, but it is definitely doable.

homm avatar Apr 01 '16 14:04 homm

Hi @homm, @Zmoki. Is there any plan to introduce this feature? I see quite old open issues that are referenced here but I am not sure if it was already implemented or not.

@vladimir-socialsweethearts hi!

We'll finish and release the methods for destroy widget early next year.

Zmoki avatar Dec 28 '17 11:12 Zmoki

@Zmoki Just wondering if there's a temporary workaround for this on already initialized widgets to clean it up?

Turbolinks (for Rails) is causing a problem as it caches the pages, and so if the back button is pressed, the same input[role='uploadcare-uploader'] is initialized multiple times.

I'm currently doing the following:

$(document).on('turbolinks:before-cache', function() { $(".uploadcare--dialog__close").trigger("click"); $(".uploadcare--dialog").remove(); $(".uploadcare--widget").remove(); })

geetfun avatar Mar 26 '18 11:03 geetfun

Any news for this issue?

anrus avatar Oct 07 '20 07:10 anrus