Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery模板插件_Jquery_Templates_Jquery Templates - Fatal编程技术网

Jquery模板插件

Jquery模板插件,jquery,templates,jquery-templates,Jquery,Templates,Jquery Templates,嘿,伙计们,我在试这个例子 关于jQuery模板和我做错的事情。 任何帮助都将不胜感激。 这是他的密码: 数据: 客户: <script id="invoiceTemplate" type="x-jquery-tmpl"> <table class="invoice"> {{each lineItems}} {{tmpl($value) get_invoiceRowTemplateName(type)}} {{/ea

嘿,伙计们,我在试这个例子

关于jQuery模板和我做错的事情。 任何帮助都将不胜感激。 这是他的密码: 数据:

客户:

  <script id="invoiceTemplate" type="x-jquery-tmpl">
      <table class="invoice">
      {{each lineItems}}
        {{tmpl($value) get_invoiceRowTemplateName(type)}}
      {{/each}}
      </table>
  </script>

{{each lineItems}}
{{tmpl($value)get_invoiceRowTemplateName(type)}
{{/每个}}
Js:

$(函数()
{
$(“#发票模板”).tmpl(发票).appendTo('body');
});
函数get\u invoiceRowTemplateName(类型){
//返回与我们的模板匹配的模板选择器
//行模板的约定。
返回“#”+类型+”行模板“;
}

不要忘记行模板:

<script id="serviceRowTemplate" type="x-jquery-tmpl">
  <tr class="service">
    <td colspan="2">${service}</td>
    <td colspan="2">${price}</td>
  </tr>
</script>

<script id="itemRowTemplate" type="x-jquery-tmpl">
  <tr class="item">
    <td>${item}</td>
    <td>${description}</td>
    <td>${price}</td>
    <td>${qty}</td>
  </tr>
</script>

${service}
${price}
${item}
${description}
${price}
${qty}

当get_invoiceRowTemplateName()将每个项目的
类型
解析为相应的*type*RowTemplate时,这些单独的行模板用于呈现每个项目。

您可能需要详细说明“错误”的含义。。。你得到输出了吗,输出有问题吗,结果有什么问题,等等etc@Ben它没有做任何事情,但Dave已经回答了我的问题,我缺少“行”模板。
$(function ()
{
    $('#invoiceTemplate').tmpl(invoice).appendTo('body');
});

function get_invoiceRowTemplateName(type) {
  // Return a template selector that matches our 
  //  convention of <type>RowTemplate.
  return '#' + type + 'RowTemplate';
}
<script id="serviceRowTemplate" type="x-jquery-tmpl">
  <tr class="service">
    <td colspan="2">${service}</td>
    <td colspan="2">${price}</td>
  </tr>
</script>

<script id="itemRowTemplate" type="x-jquery-tmpl">
  <tr class="item">
    <td>${item}</td>
    <td>${description}</td>
    <td>${price}</td>
    <td>${qty}</td>
  </tr>
</script>