Open fabien opened 8 years ago
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.
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 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(); })
Any news for this issue?
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.