2012-11-06 37 views
0

我检查了关于此主题的其他帖子,但没有一个符合我的问题。这里是我的模板代码:ICanHaz未检测到模板

<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"]没有定义,但它一直在上面的脚本标签中。有没有人知道我在这里做错了什么?

+0

看起来你有id'和'= “postingcell”''之间的空间。这是完全相同的代码吗? –

+0

它是...但只要它在字符串右边,空间不应该重要? – dopatraman

回答

3

ICanHaz也使用jQuery进行设置。一种可能的原因是您的代码在拨打电话之前运行。

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

您可以尝试调用ich.grabTemplates()在你的代码:

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