Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Matt 353 posts 825 karma points
    Oct 16, 2019 @ 09:47
    Matt
    0

    Creating accordion using nested content

    Hello,

    I'm creating an accordion with nested content, to allow the website editors to add their own content using accordions, I've created the nested content and added the partial view to the page but I'm getting the following error;

    Encountered end tag "div" with no matching start tag. Are your start/end tags properly balanced?

    Here is my code below;

    @inherits Umbraco.Web.Mvc.UmbracoViewPage
    @using ContentModels = Umbraco.Web.PublishedModels;
    
    @using Umbraco.Web.Models
    
    
    <div>Accordion View</div>
    @{
        /**/
    
        var accordionList = Model.Value<IEnumerable<IPublishedElement>>("accordionNested");
    }
    
    <div>@accordionList.Count()</div>
    
    @foreach (var panel in accordionList)
    {
    <div data-delay="600" class="accordion-item w-dropdown">
        <div class="accordion-toggle w-dropdown-toggle" data-ix="accordion-open-close">
            <div class="accordian-arrow w-icon-dropdown-toggle"></div>
            <div class="@Model.Value("accordionTitle")</div>
        </div>
        <nav class="accordion-body w-dropdown-list">
            <div class="accordion-content">
                <p>@Model.Value("accordionContent")</p><a href="#" class="faq-btn w-button">Read More </a>
            </div>
        </nav>
    </div>
        }
    

    Any idea what I'm doing wrong?

    Thanks

    Matt

  • Matt 353 posts 825 karma points
    Oct 16, 2019 @ 13:02
    Matt
    0

    Hi,

    I've now resolved the error above and now have my accordion showing which is great, my only issue is there is no text...... showing? when using @Model.Value("accordionTitle") but it displays the correct number of accordions..

        @inherits Umbraco.Web.Mvc.UmbracoViewPage
    @using ContentModels = Umbraco.Web.PublishedModels;
    @using System.Collections
    @using Umbraco.Web.Models
    
    
    
    @{
    
    
        var accordionList = Model.Value<IEnumerable<IPublishedElement>>("accordionNested");
    }
    
    <div></div>
    
    
    @foreach (var panel in accordionList)
    {
        <div data-delay="600" class="accordion-item w-dropdown">
            <div class="accordion-toggle w-dropdown-toggle" data-ix="accordion-open-close">
                <div class="accordian-arrow w-icon-dropdown-toggle"></div>
                <div class="accordion-question">@Model.Value("accordionTitle")</div>
            </div>
            <nav class="accordion-body w-dropdown-list">
                <div class="accordion-content">
                    <p>@Model.Value("accordionContent")</p><a href="#" class="faq-btn w-button">Read More </a>
                </div>
            </nav>
        </div>
    
    
    
    
    }
    
  • Matt 353 posts 825 karma points
    Oct 17, 2019 @ 07:53
    Matt
    0

    Got it working.

    Was because I was using @Model.Value instead of @panel.Value

Please Sign in or register to post replies

Write your reply to:

Draft