0

我已经检查了关于这个主题的其他帖子,但没有一个符合我的问题。这是我的模板的代码:

<script id ="postingcell" type="text/html">
    <li class="postinglistcell">
        <div class = "postinfowrapper">
            <table class="centermargins">
                <tr>
                    <td>
                        <div class="posttitle">{{Title}}</div>
                    </td>
                </tr>
            </table>
        </div>
    </li>
</script>

这是我调用 ICH 的代码:

$(document).ready(function() {
    var p = ich["postingcell"](thisobj);
});

我可以得到一个错误,告诉我ich["postingcell"]没有定义,但它已经在上面的脚本标签中。有谁知道我在这里做错了什么?

4

1 回答 1

3

ICanHaz 还使用 jQuery 进行设置。一个可能的原因是您的代码在ich.grabTemplates()调用之前运行。

if (ich.$) {
    ich.$(function () {
        ich.grabTemplates();
    });
}

您可以尝试在代码中调用ich.grabTemplates()

$(document).ready(function() {
    ich.grabTemplates();
    var p = ich["postingcell"](thisobj);
});
于 2012-11-06T04:11:19.773 回答