Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose cleanup() method #328

Open
fabien opened this issue Mar 31, 2016 · 5 comments
Open

Expose cleanup() method #328

fabien opened this issue Mar 31, 2016 · 5 comments

Comments

@fabien
Copy link

fabien commented Mar 31, 2016

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.

@homm
Copy link
Contributor

homm commented Apr 1, 2016

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.

@vladimir-socialsweethearts

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.

@Zmoki
Copy link
Contributor

Zmoki commented Dec 28, 2017

@vladimir-socialsweethearts hi!

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

@geetfun
Copy link

geetfun commented Mar 26, 2018

@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(); })

@Zmoki Zmoki added enhancement v4 and removed v4 labels May 4, 2018
@Zmoki Zmoki added this to the v4 milestone May 4, 2018
@Zmoki Zmoki removed this from the v4 milestone Jan 30, 2019
@anrus
Copy link

anrus commented Oct 7, 2020

Any news for this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

6 participants