0

モーダルが起動されると実行されるスクリプトがあります。js オブジェクトを構成する js は次のとおりです。

var source = $("#print-script").html();
var template = Handlebars.compile(source);
var data = {
    image:        image,
    title:        title,
    caption:      subtitle,
    category:     template 
};
$("#print-template").html(template(data));

すべての変数はオブジェクト宣言の上に設定され、機能しています。私のhtmlは次のとおりです。

<script id="print-script" type="text/x-handlebars-template">
<div class="print-only" id="print-template">
  <img src="{image}"/>
  <h2><span class="icon"></span>{category}</h2>
  <h3>{title}</h3>
  <p class="headline">{caption}</p>
  <div class="description">{long_description}</div>
</div>
</script>

Uncaught TypeError: Cannot read property 'image' of undefined が発生します。オブジェクト(データ)にコンテンツが取り込まれていることを確認しました。考え?

4

2 に答える 2