Sunday, 15 January 2012

knockout.js - Knockout Templates with Wijmo -


I'm trying to dynamically add a tab to a Vizzo tab with a knockout, but after compelling I get an exception addSingleExecution: (execution) - & gt; TABNAME = "#tabs - # {@ tabCounter}" tab = $ (@ targetDomElement) .wijtabs (tabTemplate: '

  • & lt; a href = "# {href}" & gt; # {label } & Lt; / a & gt; & lt; span class = "ui-icon ui-icon-pass" & gt; Remove tab & lt; / span & gt; & lt; / li & gt; 'Add: ( Event, UI) - & gt; $ (ui.panel) .append ('& lt; div data-dam = "template: {name: singleExecutionTemplate}",'.) ('/ & Gt') $ (ui .tab) .siblings ('span.ui-icon-click-close', null, self (event) -> index = $ ('li', tab). Index ($ (this) .parent ()) Tab.wijtabs ('add', moment of TABNAME (execution.date ()). Format ('DD MMM YYYY')) ko.applyBindings (execution, $ [TABNAME] [0]) @ tabCounter ++

    More obvious exceptions I have a line of knockout 2.2.1 debug at 3008:

      Uncaught TypeError : An array of dom node null property can not be read 'length' // is loosely checking the result if ((typeof renderedNodesArray.length = "number") || (renderedNodesArray.length & gt;! 0 & amp; & Amp;! Typeof renderedNodesArray [0] .nodeType = "number")) Uncaught TypeErr or: Throwing property can not be read 'length' of the new error ("template engine should return an array of dom nodes");   

    This is my template

      & lt; Script type = "text / html" id = "singleExecutionTemplate" & gt; & Lt; Div & gt; & Lt; Ul & gt; & Lt; Li & gt; & Lt; H1 & gt; Step 1 & lt; / H1> Set input data & lt; / Li & gt; & Lt; Li & gt; & Lt; H1 & gt; Step 2 & lt; / H1> This is the second step & lt; / Li & gt; & Lt; Li & gt; & Lt; H1 & gt; Step 3 & lt; / H1> Analyze results and records & lt; / Li & gt; & Lt; / Ul & gt; & Lt; Div & gt; Setup & lt; / Div & gt; & Lt; Div & gt; Run & lt; / Div & gt; & Lt; Div & gt; Analyze & lt; / Div & gt; & Lt; / Div & gt; & Lt; / Script & gt;   

    Why is it not rendered correctly?

    I took part in this, I was switching to ASP.Net MVC using the razor template Was there. The difference in the markup was subtle and without the answer given by Edmondo 1984, I never caught my mistake.

    Yes, this would be a string asset with a razor, I had to change my form:

        

    Hope this helps.

  • No comments:

    Post a Comment