开发者

Jquery Templates doesn't show up in IE

开发者 https://www.devze.com 2023-01-18 18:47 出处:网络
I was trying to use the jquery templates (http://stanlemon.net/projects/jquery-templates.html). What I am trying to do

I was trying to use the jquery templates (http://stanlemon.net/projects/jquery-templates.html).

What I am trying to do

I am trying to fetch an array of objects through JSON and render them using开发者_如何学C the jquery templates. I get the JSON as follows

[{"type":"todo","title":"sample task","description":"this is description","tags":["todo","delete"],"objectId":"2"},{"type":"todo","title":"Do it right now","description":"you have to do everything","tags":["todo","delete"],"objectId":"3"}]

And to render it using the jquery template plugin, I do the following

for(var i=0; i<data.length; i++)
{
  var task = data[i];
  //alert('hello');
  $('#tasks').append($.template(taskTemplate), task);
}

What happens

This works fine in firefox and chrome but not in IE (I have v8). The for loop is executed but nothing is rendered in the #tasks div. The weird thing I noticed is that if I uncomment the alert in for loop, things are rendered properly after every pop up.

What could be the problem? please help! Thanks in advance :)


I had the exactly same issue. My problem was to remove an empty div tag with a clear class. try removing elements one by one until the markup is shown. Worked for me.

I see jquery templates are staying in beta for the time being. You may want to move to knockoutjs or handlebarsjs js templates that as of 14/04/2012 has active support.

Perhaps not the technical answer you were looking for but hope it helps.


I just found a bug in the original jquery templates:

just save the file and edit it:

at line 428 replace

pntItem && pntItem.key != pntNode

with

pntItem != undefined && pntItem.nodes != undefined && pntItem.key != pntNode

That worked for me (Tested with IE9: IE9 was giving me an error at that exact line in my script)

0

精彩评论

暂无评论...
验证码 换一张
取 消