I am currently struggling to understand why the last child of the li element is not being inserted into the last li. This module functions as a treeview, and my main objective is to add a class to the last li.
Let me demonstrate with some sample code and illustrations below:
As you can see, the added class is on a different li element when it should be on the check mark.
Problem: The added class ('last') is not appearing on the correct last li.
I have two HTML pages:
- posting.blade.php
- manage_child.blade.php
https://i.sstatic.net/mZLsf.png
posting.blade.php:
<ul id="tree1">
@foreach($categories as $category)
<li>
{{ $category->title }}
@if(count($category->childs))
@include('/SuperAdmin/manage_child',['childs' => $category->childs])
@endif
</li>
@endforeach
</ul>
manage_child.blade.php:
<ul>
@foreach($childs as $child)
<li>
{{ $child->title }}
@if(count($child->childs))
@include('/SuperAdmin/manage_child',['childs' => $child->childs])
@endif
</li>
@endforeach
</ul>
Treeview Js:
$.fn.extend({
treed: function (o) {
var openedClass = 'far fa-minus-square';
var closedClass = 'far fa-plus-square';
if (typeof o != 'undefined'){
if (typeof o.openedClass != 'undefined'){
openedClass = o.openedClass;
}
if (typeof o.closedClass != 'undefined'){
closedClass = o.closedClass;
}
};
// Rest of the JS code...
}
});
// Initialization of treeviews
$('#tree1').treed();
CSS:
#tree1, #tree1 ul {
margin:0;
padding:0;
list-style:none
}
// Rest of the CSS code...
Additionally, I want to remove the yellow background of the children with the .branch class.