javascript - Expand/Collapsible list of objects -



javascript - Expand/Collapsible list of objects -

i'm trying display list of object models (robots), models have field parent can robot.

i've implemented nested list using mptt django:

{% load mptt_tags %} <ul> {% recursetree nodes %} <li> <a href="{{ node.get_absolute_url }}">{{ node.name }}</a> {% if not node.is_leaf_node %} <ul class="children"> {{ children }} </ul> {% endif %} </li> {% endrecursetree %} </ul>

i'd create list exandable/collapsable - eg can shrink nodes children. i'm having problem using javascript because nodes of same class. there other simple way of implementing this?

you can figure out level you're @ in tree using node.level, need add together additional css class top level, this:

<ul id="node-{{ node.pk }}" class="children{% if node.level==0 %} top_level{% endif %}">

node.tree_id interesting instead of pk

javascript python html django

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -