> I think i am getting a tad closer i am trying to find out how i can make
> multi rows with a
> for loop then insert them in to the table or just put them in a var in
> the deleration of the table
> it self. I have been looking at this callender.js and i am a tad confused :(
>
> var days = [];
> for (var i=0; i<this.data['days'].length; i++)
> days[i] = { 'node' : "th", 'class' : this.classes['day-name'], 'content' : 
> this.data['days'][i] };
> return [ 'tr', {}, [ $.tpl( days, this.tpl['cell'] ) ] ];
>
> This code look sto be what i need just de coding it is a tad hard hehe.
> I am assuming that $.tpl will do what i want? It takes a json array then 
> produces multi rows from it?

first $.tpl() argument must be json or simple array, second - template function.
$.tpl just loops through array and applies "template function" to
every item. Result of "template function" runs through $.dom() and in
the end you have jQuery object with created elements

But I recommend use $.dom plugin only in XHTML pages with MIME type
application/xhtml+xml
http://www.quirksmode.org/bugreports/archives/2004/11/innerhtml_in_xh.html

Easier and faster solution is innerHTML
http://www.quirksmode.org/dom/innerhtml.html

For example:
var json = [
   {'name' : "John", 'surname' : "Smith"},
   {'name' : "Sarra", 'surname' : "Smith"}
];

var table = $('#fill-table > tbody');
$.each(json, function(){
   table.append('<tr class="MyTableRow">'
      +'<td class="MyTableCol1">'+ this.name
      +'<td class="MyTableCol2">'+ this.surname
   +'</tr>');
});

> There is also this method
> http://mg.to/2006/02/27/easy-dom-creation-for-jquery-and-prototype#comment-176
>
> I am assuming it is the same author?

Yes author is the same. Me. :)

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to