Search code examples
cookiesjstree

jstree cookie unset


I am using Jstree in my web project and add the "cookies" plugin.

There are few problems with it

First, when I close a node, the cookie won't remember it. And after I refreshed the page, the closed node will be opened again. How to let cookie knows that I closed a node?

Second, is there way to unset the cookie just with Jstree cookies plugin? If not, can I do it with Jquery.cookie plugin? How?

Third, Can I access and change the content of cookies (of jstree!)? like manually set the selected_node or opened_node?

Last, Jsree has a attribute named initially_select. Basically, it is no longer useful due to the cookie. Is there any way to let them both work?

Thanks for any help!


Solution

  • After some research I think this question deserved a proper end.

    Basically, there is no build-in method for unset the cookies of jstree. So if you really want to unset it, the only way to do it is to maintain the cookies by you self.

    There are several cookie collections you need to be aware of.

    "To load" and "to open". This two field of cookies store the info that jstree required to reset the tree after each refreshing or redirecting. So if you are able to removing or adding node from or to those field, you are, kind of, maintain the cookies by you own.

    And there is an issue you should know that if a node is remove from "to load" field, but any of its children still remained, then jstree will automatically add this parent node back the list. So you have to handle the this parent-child relationship.

    Basically, I think it is not to achieve the goal that to unset the cookie.

    Hope this post helps.