Resetting data in plugins

Hello!

Sometimes plugins can be perfect, sometimes we use it with glitches. For the product that needs a little more care, we don’t always get a quick response when we contact the relevant developers.

In my case, it was a terrible UX experience because I couldn’t reset the data on a plugin.

When I asked to a friend what I could do as an alternative, he came back with a super favor :slight_smile: Thanks a lot @lottemint.md

This code, which you can use with the Toolbox plugin, can reset the data on the plugins.

You can watch the gif for File Uploads> 50mb and Video Capture and Browser plugins. In theory, it should work on all plugins, I tested with these two.

Here is the code

function resetUploadCare() {

try {
    let states = $('#plugin-uploadcare')[0].bubble_data.bubble_instance._states;

    for (let i = 0; i < Object.keys(states).length; i++) {

        let cell = Object.keys(states)[i];

        states[cell](null)
    }
} catch (e) {
    
    let message = 'function resetUploadCare error: ' + e.message;

    console.log(message)
    }
}

resetUploadCare();

Attention to element IDs

It’s done!

:clap::clap::clap: @lottemint.md :clap::clap::clap:

8 Likes

You both are great, @eren and @lottemint.md :slight_smile:

Sent this to our js team to see if we can use the same solution to fix the issue with our Uploadcare plugin :sweat_smile:

Thanks a lot guys :pray:

1 Like

Thanks for this :heart:

mhh little question.

I used this javascript to clear the “Multi uploader” pluggin from codesavvy.

Indeed when I launch the javascript, the list of all files is cleared.
However, this is only a temporary deletion.
If ever I want to upload a new file in the uploader I’ve just reset. It adds the file in question to the uploader, but also all the files that are supposed to be “deleted”…

Any idea how to avoid this behavior and really delete the plugin’s elements so that I can add new ones without having to refresh the page?

Thanks