Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

mustache data helper template: malformed

$
0
0
Hi! I'm completly new in CanJS (noob on JS generally), i'm playing with the recipes and getting started to learn, but in one recipe i have this issue:

When i render the template in the browser, console throw's me an "malformed" message in the main.hgn template, the code is basic:

  1. <ul>
    {{#each people}}
      <li {{data 'person'}}>
        {{lastname}}, {{firstname}}
      </li>
    {{/each}}
    </ul>
And the JS:

  1. var peopleList = can.Control({
      init: function (element, options) {
        this.options = new can.List(options.people);
        this.element.html(can.view('views/main.hgn', { people: this.people }));
      },
      'li click': function (li, ev) {
        var people = this.options.people;
        var person = li.data('person');
        var index = people.indexOf(person);

        people.splice(index, 1);
      }
    });

    var people = [
      {firstname: "John", lastname: "Doe"},
      {firstname: "Emily", lastname: "Dickinson"},
      {firstname: "William", lastname: "Adams"},
      {firstname: "Stevie", lastname: "Nicks"},
      {firstname: "Bob", lastname: "Barker"}
    ];

    new peopleList('#my-app', { people: people });
The recipe's code is exactly the same (i just break down all in folders), so ¿What i'm doing wrong? D:

Thanks for all answers!

PD: sorry about my bad english u.u

Viewing all articles
Browse latest Browse all 3491

Trending Articles