javascripttemplate-engineicanhaz.js

ICanHaz Not detecting template


I've checked the other posts on this topic, but none of them match my problem. Here is the code for my template:

<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>

And here is the code where I call the ICH:

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

I can get an error telling me that ich["postingcell"] is not defined, but it has been in the above script tag. Does anyone know what im doing wrong here?


Solution

  • ICanHaz also uses jQuery for setting up. One possible reason is your code runs before the ich.grabTemplates() call.

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

    You may try calling ich.grabTemplates() in your code:

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