D
D
des1roer2015-04-27 07:15:56
JavaScript
des1roer, 2015-04-27 07:15:56

Yii remember tree state?

There is such a task - to remember the state of the tree. I think to write in session. from here we have - you need js to find out the style of the object console.log(document.getElementById('13').classList.contains('open'));
and somehow pass it to the controller, and then save it to the array. very vague idea how to do it
on click

document.getElementById("tree").onclick = new Function("console.log(this)");

gives a
<ul id="tree" class="filetree treeview">
problem in what
<ul>
<li id="13" class="closed expandable">
<li id="45" class="closed expandable">
<li id="6" class="closed expandable">
<div class="hitarea closed-hitarea expandable-hitarea"></div>
<a class="" href="/proizvodstvo/site/page?view=frameset&frame=6">ЛАЦ</a>
<ul style="display: none;">
</li>
<li id="2" class="closed expandable lastExpandable">
<div class="hitarea closed-hitarea collapsable-hitarea lastCollapsable-hitarea"></div>
<a class="" href="/proizvodstvo/site/page?view=frameset&frame=2">страница</a>
<ul style="display: block;">

that is, the trickster does not have an id diva. but li has an id. How can you refer to an ancestor?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sharov Dmitry, 2015-04-27
@vlom88

Try using jquery cookies

$('#tree').click(function(){
    if($(this).hasClass('treeview')){
        $.cookie('treeview', 'true');
    } else {
        $.cookie('treeview', 'false');
    }
})

When reloading the page, see the state of $_COOKIE['treeview']

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question