lucaong / jQCloud

jQuery plugin for drawing neat word clouds that actually look like clouds
MIT License
646 stars 293 forks source link

How Can I Clear wordcloud #61

Open zw231212 opened 7 years ago

zw231212 commented 7 years ago

When I use a select tag to change wordcloud's size(use ajax) ,the former words maybe overlap words now。Then I use $(...).html("") to clear the former wordcloud ,but when the former wordcloud is still rendering , I change the word number, then words could overlap.

Is there a safety param or method to clear the former wordcloud?

code eg:

$("#queryrecordWordCloud").html(" ");//clear former wordcloud
var word_array = [];
$.ajax({
    "url":"...",
    "type":"POST",
    "data":{},
    "dataType":"JSON",
    "async":false,
    success:function (data) {
        word_array=data;
    },
    error:function () {
        //...
    }
});
$("#queryrecordWordCloud").jQCloud(word_array);//render wordcloud
pallaviMN commented 7 years ago

@zw231212 , did u get any solution for this problem?

zw231212 commented 7 years ago

@pallaviMN No,When It is rendering,Just not to choose change the size.

churcho commented 7 years ago

I came across this error as well and on inspecting the div, I realised that the words are enclosed in span tags. To clear the div use $('#div-id').find('span').remove(). One thing I also noticed is that sometimes I would execute the clear command while the word rendering is not complete, you can overcome this by setting delayedMode' to false or only calling the re-render if a flag is true and you'd set that flag to true by using theafterWordRender` callback function.

Hope that helps someone else who lands here :-)