Copied to clipboard

Flag this post as spam?

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


  • Johan 95 posts 264 karma points
    Dec 09, 2015 @ 18:21
    Johan
    0

    How to make javascript and HTML read document type?

    I'm working on a filter and I'm stuck.

    I've worked on a html filter and javascript that works for filtering, however it doesn't work on Umbraco for obvious reasons.

    @inherits UmbracoTemplatePage
    @using ClientDependency.Core.Mvc
    @{
        var schools = CurrentPage.Children.OrderBy("kommun");
    }
    
    <dl>
                    <dt>
                        <a href="#">
                            <span class="hida">Select</span>
                            <p class="multiSel"></p>
                        </a>
                    </dt>
    
                    <dd>
                        <div class="mutliSelect">
                            <ul>
                                <li>
                                    <input name="tablefilter" type="checkbox" value="Linköping" id='tablefilter1' checked />Linköping
                                </li>
                                <li>
                                    <input name="tablefilter" type="checkbox" value="Norrköping" id='tablefilter2' checked />Norrköping
                                </li>
                                <li>
                                    <input name="tablefilter" type="checkbox" value="Mjölby" id='tablefilter3' checked />Mjölby
                                </li>
                            </ul>
                        </div>
                    </dd>
                </dl>
    
                <div id="no-more-tables" class="sorttable">
    
                    <table>
                        <thead>
                            <tr>
                                <th style="width: 15%;" data-sort-initial="true">
                                    Kommun
                                </th>
                                <th style="width: 20%;">
                                    Skola
                                </th>
                                <th style="width: 15%;">
                                    Datum
                                </th>
                                <th style="width: 15%;" data-sort-ignore="true">
                                    Tid
                                </th>
                                <th style="width: 20%;" data-sort-ignore="true">
                                    Adress
                                </th>
                                <th style="width: 15%;" data-sort-ignore="true">
                                    Övrigt
                                </th>
                            </tr>
                        </thead>
    
                        <tbody id='tablebody'>
    
                            @foreach (var school in schools)
                            {
                                var times = school.Children.Where("date > DateTime.Now.Date").OrderBy("date");
    
                                foreach (var time in times)
                                {
                                    <tr>
                                        <td data-title="Kommun">
                                            @if (!string.IsNullOrEmpty(school.kommun))
                                            {
                                                @school.kommun
                                            }
                                            else
                                            {
                                                <text>&nbsp;</text>
                                            }
                                        </td>
                                        <td data-title="Skola">
                                            @if (!string.IsNullOrEmpty(school.Name))
                                            {
                                                @school.Name
                                            }
                                            else
                                            {
                                                <text>&nbsp;</text>
                                            }
                                        </td>
                                        <td data-title="Datum">
                                            @if (time.date != null)
                                            {
                                                @time.date.ToString("yyyy-MM-dd")
                                            }
                                            else
                                            {
                                                <text>&nbsp;</text>
                                            }
                                        </td>
                                        <td data-title="Tid">
                                            @if (!string.IsNullOrEmpty(time.time))
                                            {
                                                @time.time
                                            }
                                            else
                                            {
                                                <text>&nbsp;</text>
                                            }
                                        </td>
                                        <td data-title="Adress">
                                            @if (!string.IsNullOrEmpty(school.adress))
                                            {
                                                @school.adress
                                            }
                                            else
                                            {
                                                <text>&nbsp;</text>
                                            }
                                        </td>
                                        <td data-title="Övrigt">
                                            @if (!string.IsNullOrEmpty(school.oevrigt.ToString()))
                                            {
                                                @school.oevrigt
                                            }
                                            else
                                            {
                                                <text>&nbsp;</text>
                                            }
                                        </td>
    
                                    </tr>
                                }
                            }
    
                        </tbody>
                    </table>
    
                </div>
    

    The problem is the table:

    <td data-title="Kommun">
                                            @if (!string.IsNullOrEmpty(school.kommun))
                                            {
                                                @school.kommun
                                            }
                                            else
                                            {
                                                <text>&nbsp;</text>
                                            }
                                        </td>
    

    Normal html and JavaScript can't read it. It's a document type. How can I make it readable for the HTML and javascript?

Please Sign in or register to post replies

Write your reply to:

Draft