Question

I have converted my ugly data parsing logic to Mustache (for http://loop.pk). Pretty neat stuff. I do all my development in Ubuntu/Linux so I didn't notice but the Data doesn't show up in IE.

I have traced down error to this line, the "data" is perfect, populated and as expected. Don't know why this fails.

$('#template_smslist').mustache(data).prependTo('#tab_inbox');

Here's how my template looks:

{{#sms}}
<div class="sms_recvd sms_list a">
    <div class="sms_list_text">{{text}}</div>
    <div class="sms_list_time">{{tstamp}}</div>
</div>
{{/sms}}

And here's how data looks like:

{"sms":[{"id":"1727591","text":"Fb shabantoo","tstamp":"1315597361"},{"id":"1727580","text":"Fb and dj shahruk rocking it again","tstamp":"1315597106"},{"id":"1727466","text":"Fb i see unicorns","tstamp":"1315595994"},{"id":"1727214","text":"Fb i see rainbows","tstamp":"1315593322"}.............

Please help!

Was it helpful?

Solution

I'm assuming you have the template inside a script tag, something like:

<script type="text/x-mustache-tmpl" id="template_smslist">
...
</script>

And it looks like you're using https://github.com/thinkdevcode/jQuery-Mustache which appears to be the problem here...

So, all it basically does is to return

$(Mustache.to_html($('#template_smslist').text(), data))

but in IE the text() calls returns nothing. Instead if html() was used it would work in all browsers.

So, my suggestion is to just do:

$(Mustache.to_html($('#template_smslist').html(), data))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top