Und definierte an landaltreueJquery

JQuery-Programmierung
Anonymous
 Und definierte an landaltreue

Post by Anonymous »

Ich habe gerade mit Lenker begonnen und in ein kleines Problem gestoßen. Alles funktioniert gut, meine Daten werden in die Vorlage gezogen und die Daten werden wie erwartet angezeigt, aber ich erhalte diesen Fehler weiter. < /P>

Code: Select all

Error: You must pass a string or Handlebars AST to Handlebars.compile. You passed undefined
Wenn ich die Quelle in der Konsole protokolliere, weiß ich, dass es sich nicht um eine Zeichenfolge handelt, aber dies ist, was in diesem Tutorial http://javascriptplayground.com/blog/20 ... -tutorial/ erklärt wird. Bin ich falsch? < /P>

Code: Select all

    {{#sets}}
[*]
{{title}}
[img]{{img}}[/img]

{{/sets}}

Here is the rest of it

HTML



[list]

{{#sets}}
[*]
{{title}}
[img]{{img}}[/img]

{{/sets}}

[/list]



jQuery

function getProductsSets() {
$.getJSON('products/products.json', {
format: "json"
}).done(function(json) {
$.each(json.sets, function() {
var source = $('#full-sets-template-mobile').html();
console.log(source)
var template = Handlebars.compile(source);
var data = template(json);
var html = $('#sets-template-inner').html(data);
});
}).fail(function() {
console.log('failed');
});
}

JSON

{
"sets":
[
{
"title": "raw bones",
"img": "img/sets/set1.jpg",
"desc": "Raw pine table with 2 chairs and a bench.",
"base": 1200,
"seating":
[
{
"price": 0,
"name": "4 seater"
},
{
"price": 400,
"name": "6 seater"
},
{
"price": 800,
"name": "8 seater"
}
]
},
{
"title": "sky blue",
"img": "img/sets/set1.jpg",
"desc": "Raw pine table with 2 chairs and a bench",
"base": 1300,
"seating":
[
{
"price": 0,
"name": "4 seater"
},
{
"price": 500,
"name": "6 seater"
},
{
"price": 800,
"name": "8 seater"
}
]
}
]
}
Ich hoffe, ich habe hier genug Informationen und danke für jede Hilfe.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post