Tuesday, 10 September 2013

Knockout Error: Cannot find closing comment tag to match

Knockout Error: Cannot find closing comment tag to match

This may seem like a duplicate question, but none of the other answers
have helped me. I have the following HTML (it's a Razor template, but no
Razor specifics here).
<p class="search-results-summary">
Results
<!-- ko if: SearchTerms.Query -->
for <span data-bind="html: SearchTerms.Query"></span>
<!-- /ko -->
<!-- ko if: SearchTerms.Names -->
for Names <span data-bind="html: SearchTerms.Names.join(', ')"></span>
<!-- /ko -->
<!-- ko if: SearchTerms.Location && AlternativeLocations &&
AlternativeLocations.length -->
within <span data-bind="text: SearchTerms.LocationRadio"></span>
miles of <span data-bind="html: SearchTerms.Location"></span>.
<!-- ko if: AlternativeLocations && AlternativeLocations.length >
1 -->
<a class="more alternative-locations" href="#">more</a>
<ul id="other-location-matches" data-bind="foreach:
AlternativeLocations.slice(1).sort()" style="display: none">
<li>&gt; Did you mean <a data-bind="html: $data, attr: {
href: Edge.API.CurrentSearchResponse.SearchTerms.mutate({
Location: $data }).getUrl() }"></a>?</li>
</ul>
<!-- /ko -->
<!-- /ko -->
<!-- ko if: SearchTerms.Location && (!AlternativeLocations ||
AlternativeLocations.length == 0) -->
<span class="error">We couldn't find '<span data-bind="html:
SearchTerms.Location"></span>' on the map. Your search ran Worldwide.
</span>
<!-- /ko -->
</p>
When I try to bind this template using Knockout, I get this error:
Error: Cannot find closing comment tag to match: ko if:
SearchTerms.Location && AlternativeLocations &&
AlternativeLocations.length
I have tried:
Upgrading Knockout from 2.2.1 to 2.3.0. No use
Verifying HTML/XML structure. It's good!
Removing the <ul id="other-location-matches"...> seems to get rid of the
issue... but I need that <ul>!!
Any ideas? Am I looking at a Knockout.js bug?

No comments:

Post a Comment