Tree view on my page

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 years ago
Hey guys

I made a page on topics section and after that I add my Html codes in this page. These codes
make a tree view  list for TV channels .by click you can open and close it.now the problem is when I copy these code and past in source code portion, the button doesn't work properly.
please guide me.

here is my code:

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
ul, #myUL {
  list-style-type: none;
}
#myUL {
  margin: 0;
  padding: 0;
}
.caret {
  cursor: pointer;
  -webkit-user-select: none; /* Safari 3.1+ */
  -moz-user-select: none; /* Firefox 2+ */
  -ms-user-select: none; /* IE 10+ */
  user-select: none;
}
.caret::before {
  content: "\25B6";
  color: black;
  display: inline-block;
  margin-right: 6px;
}
.caret-down::before {
  -ms-transform: rotate(90deg); /* IE 9 */
  -webkit-transform: rotate(90deg); /* Safari */'
  transform: rotate(90deg);  
}

.nested {
  display: none;
}

.active {
  display: block;
}
</style>
</head>
<body>

<ul id="myUL">
  <li><span class="caret">Channel list</span>
    <ul class="nested">
      <li>Channel 1</li>
      <li>Channel 2</li>
      
            </ul>
          </li>
        </ul>
     <script>
  var toggler = document.getElementsByClassName("caret");
var i;

for (i = 0; i < toggler.length; i++) {
  toggler[i].addEventListener("click", function() {
    this.parentElement.querySelector(".nested").classList.toggle("active");
    this.classList.toggle("caret-down");
  });
}

</script>


</body>
</html>
3 years ago
asadisa243 wrote:
[quote=asadisa243]<html><head></head><body></body></html>

The first problem is you already have these elements on the page
The next problem is the script will not get loaded

So you need to customise to do it - one way is to make a custom .cshtml component
add the script using similar to
    Html.AppendScriptParts(ResourceLocation.Footer, "~/js/public.countryselect.js");
and include it as a component on the
4.30_Source\Presentation\Nop.Web\Views\Topic\TopicDetails.cshtml page
using something like
@await Component.InvokeAsync("SocialButtons")
3 years ago
I appreciate  Yinda
it is working. thank you
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.