0

When I run the code below I get the:

{{each(index,friend)friends}}
    '<'li>${name}'<'/li>
    {{/each}}

printed on the screen instead of the array elements I don't know if this has anything to do with HTML5. Also I added the jquery,konckout references and checked the syntax.

    '<'h1>Friends'<'/h1>

'<'div data-bind="template: 'friendsTemplate'">'<'/div>



'<'script id="friendsTemplate" type="text/html"'>'
'<'ul>
    {{each(index,friend)friends}}
    '<'li>${name}'<'/li>
    {{/each}}
'<'/ul>

 '<'script type="text/javascript"'>'
    function friend(name) {
        return { name: ko.observable(name) };
    }

    var viewModel = {

        friends: ko.observableArray([new friend("Ram"), new friend("Sam")]),
        addFriend: function () {
            this.friends.push(new friend("Another Guy"));
        }
    };


     ko.applyBindings(viewModel);

     
/////////
2
  • 2
    You are using the jquery tmpl syntax here, have you included the jquery and the jquery tmpl plugin? Commented Jul 29, 2013 at 20:38
  • Yes I Included, also i debugged the js with fire bug no errors was found Commented Jul 29, 2013 at 21:07

1 Answer 1

0

you can try giving the script tag of your template an invalid mime type like..

<script id="friendsTemplate" type="text/x-jquery"'>

also try modifying your template each synatx to

{{each friends}}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.