Knockout virtual label (dummy element) problem in table

Source: Internet
Author: User
Tags foreach bind closing tag closure comment tag

These days to see some of the mvc4/5 things, basically and MVC 3 are the same, looks effortless, the project has not officially started, every day is to see the document, understand technology. Idle bored on the knockout JS to see it again. Today, while looking at SIGNALR, I wrote a paragraph of test code, found that the virtual label knockout a bit of a problem, at first I wrote this:

<table> <tr data-bind= "Foreach:msgs" > <td data-bind= "text:name" ></td> <TD data-bind= "text:msg" ></td> </tr> </table>

The discovery loop occurs on the TD's internal, which generates columns instead of rows.

Into:

<table>
        <!--ko foreach:msgs-->
        <tr>
            <td data-bind= "Text:name" ></td>
            <td data-bind= "text:msg" ></td>
        </tr>
        <!--/ko-->  
</table>

Incredibly hint:

Cannot find closing comment tag to Match:ko foreach:msgs

Read the HTML carefully, did not find a closed tag, the syntax is not wrong. TD Riga content also no avail.

To navigate to the Knockout-3.1.0.debug.js Getvirtualchildren method, the incoming argument is a Comment, that is, the virtual label.

Looking at its father to look like who:

The following is followed by a while loop:

while (CurrentNode = currentnode.nextsibling) {

The goal is to loop the judgment and the Comment at the same level is not a Comment, that is, at the same level to find the virtual label of the closing tag, unfortunately, in the upper part of the HTML, did not find the closure of the virtual tag, but on the surface, It does have a corresponding closure.

Why is that?

Back to the column page: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/script/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.