Re: [jQuery] jQDOM - My entry into the jQuery DOM creation foray
I think this is a great plugin and actually something I've wished for in the past, despite jQuerys already present built in functions and another DOM creation library I already use. So to mee, this is good :D andreas ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] jQDOM - My entry into the jQuery DOM creation foray
That would result in adding the following code to the body: div align=right class=my_div http://alterform.com Alterform /div I think DOM tools are great for working with nasty things like tables, but jQuery handles simple insertions quite well on its own. Your example could be written more succinctly like this: $('body').append('div align=right class=my_diva href=http://jquery.com;jQuery/a/div'); ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] jQDOM - My entry into the jQuery DOM creation foray
Hi Nate, I just reread my last message and it seems very negative - I didn't mean for it to sound that way. Your plugin is cool and quite tiny! Nice work. Mike ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] jQDOM - My entry into the jQuery DOM creation foray
I didn't take it that way, so don't worry :) The problem I have with jQuery's native methods is that sometimes, you want to be able to operate on a specific object while you're creating it. So, for instance, with that link inside that div, sometimes as I create it, I'd like to attach an event to JUST that anchor tag, rather than having to create a custom ID, assign it, then do another jQuery call to bring it up and attach an event. The quickest way, of course is jQuery's native methods, but my plugin is just trying to fill the gaps some on those times when you need to manipulate and/or create actual DOM elements. Thanks again for your comments :) malsup wrote: Hi Nate, I just reread my last message and it seems very negative - I didn't mean for it to sound that way. Your plugin is cool and quite tiny! Nice work. Mike ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- View this message in context: http://www.nabble.com/jQDOM---My-entry-into-the-jQuery-DOM-creation-foray-tf3126694.html#a8667859 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] jQDOM - My entry into the jQuery DOM creation foray
So, for instance, with that link inside that div, sometimes as I create it, I'd like to attach an event to JUST that anchor tag, rather than having to create a custom ID, assign it, then do another jQuery call to bring it up and attach an event. Still doable, but less readable: $('a href=jQueryjQuery/a').appendTo($('div align=right class=my_div').appendTo('body')).click(function(){ alert('Ouch'); return false; }); I hear what you're saying though. Sometimes you want that dom element on its own. And too much chaining can make reading and debugging difficult. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] jQDOM - My entry into the jQuery DOM creation foray
Mike Alsup wrote: So, for instance, with that link inside that div, sometimes as I create it, I'd like to attach an event to JUST that anchor tag, rather than having to create a custom ID, assign it, then do another jQuery call to bring it up and attach an event. Still doable, but less readable: $('a href=jQueryjQuery/a').appendTo($('div align=right class=my_div').appendTo('body')).click(function(){ alert('Ouch'); return false; }); I hear what you're saying though. Sometimes you want that dom element on its own. And too much chaining can make reading and debugging difficult. I think you can do: var a = $('a href=jQueryjQuery/a')[0]; -- Klaus ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] jQDOM - My entry into the jQuery DOM creation foray
Personally, I didn't like any of the current DOM creation plugins out there for jQuery. So I created my own, and here it is :) http://www.alterform.com/resources/jqdom Examples and documentation are on the page, but a simple example of adding some dom Elements to the page: $('body').dom('div').attr({align:'right','class':'my_div'}).dom('a').attr({href:'http://alterform.com'}).text('Alterform').end().end(); That would result in adding the following code to the body: div align=right class=my_div http://alterform.com Alterform /div And don't worry, if you only want to store DOM elements into variables for operating on them later, there is a way to do that too with $.dom(); Okay, enough rambling from me. Enjoi...http://www.alterform.com/resources/jqdom -- View this message in context: http://www.nabble.com/jQDOM---My-entry-into-the-jQuery-DOM-creation-foray-tf3126694.html#a8663077 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Dom creation
On 17/08/06, Michael Geary [EMAIL PROTECTED] wrote: From: Aloyzas Rimeika ...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'); }); I'm with you there. I have switched most of my code from DOM creation to innerHTML. BTW, you can speed up this kind of code by using Array.join instead of string concatenation: var table = $('#fill-table tbody'); $.each(json, function(){ table.append( [ 'tr class=MyTableRow', 'td class=MyTableCol1', this.name, '/td', 'td class=MyTableCol2', this.surname, '/td', '/tr' ].join('') ); }); It won't make a huge difference in a simple case like this, but if you're concatenating very many strings, Array.join really speeds things up in most browsers. -Mike Doesn't this work: $('#fill-table tbody').append(json, [ 'tr class=MyTableRow', 'td class=MyTableCol1', this.name, '/td', 'td class=MyTableCol2', this.surname, '/td', '/tr' ].join(''); ); If not, perhaps it should be added to jQuery? ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Dom creation
Doesn't this work: $('#fill-table tbody').append(json, [ 'tr class=MyTableRow', 'td class=MyTableCol1', this.name, '/td', 'td class=MyTableCol2', this.surname, '/td', '/tr' ].join(''); ); If not, perhaps it should be added to jQuery? Not the json/templating stuff - but you can append trs to both tables and tbodys (jQuery takes care of all the innerHTML details to make it work cross browser). --John ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Dom creation
Hey things seem to be going along nicely just need a push over the edge :) http://3spn.net/jQuery/dom_creation.html I have constructed a dummy array i need to figure out how to transverse and access the data i know it should be simple reading around now might not need help. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Dom creation
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; ithis.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? 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? and the example there shows that it has the ability to create rows? var json = [ {'name' : John, 'surname' : Smith}, {'name' : Sarra, 'surname' : Smith} ]; $.tpl(json, function(){ return [ 'tr', { 'class':MyTableRow }, [ 'td', { 'class':MyTableCol1 }, [ this.name ], 'td', { 'class':MyTableCol2 }, [ this.surname ]] ]; }).appendTo($('#fill-table tbody').get(0)); Dave Methvin wrote: How would i go about making a table and then inserting rows in the body in a for loop. I am wanting to create a stats board for a post match. I figured i would create the table and then append to it am i right in how to go about this? How would i append to a tag in the table i just created? http://3spn.net/jQuery/dom_creation.html I wanted to add more player rows how would i do that? hehe I tried to do a append($table tr) deal but it didnt work. The tr elements descend from either thead or tbody, so tabletr won't match anything. There's a workaround in the latest jQuery that will catch the case of appending tr to table and put it in tbody, but it's best to say it yourself. Instead of applying a style to each td, use a colgroup and apply the styles (or classes) to the col elements. It will save you a lot of messy coding. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Dom creation
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; ithis.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 discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Dom creation
How would i go about making a table and then inserting rows in the body in a for loop. I am wanting to create a stats board for a post match. I figured i would create the table and then append to it am i right in how to go about this? How would i append to a tag in the table i just created? http://3spn.net/jQuery/dom_creation.html I wanted to add more player rows how would i do that? hehe I tried to do a append($table tr) deal but it didnt work. The tr elements descend from either thead or tbody, so tabletr won't match anything. There's a workaround in the latest jQuery that will catch the case of appending tr to table and put it in tbody, but it's best to say it yourself. Instead of applying a style to each td, use a colgroup and apply the styles (or classes) to the col elements. It will save you a lot of messy coding. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Dom creation
Working great. How would i go about making a table and then inserting rows in the body in a for loop. I am wanting to create a stats board for a post match. I figured i would create the table and then append to it am i right in how to go about this? How would i append to a tag in the table i just created? http://3spn.net/jQuery/dom_creation.html I wanted to add more player rows how would i do that? hehe i tried to do a append($table tr) deal but it didnt work. Aloyzas Rimeika wrote: Ups. :) http://www.aloyzas.lt/javascript/jquery-dev/dom.js Basically I am waiting for jQuery 1.0 release... On 8/9/06, Jason Yeckel [EMAIL PROTECTED] wrote: Does not work with the latest svn but it works with 1.0a. you gave me the same link :) i did try a newier svn first though just to check still no go. Aloyzas Rimeika wrote: Maybe this one will work :) http://www.aloyzas.lt/javascript/jquery/dom.js On 8/9/06, Jason Yeckel [EMAIL PROTECTED] wrote: ttp://www.aloyzas.lt/javascript/jquery/dom.js Will this be updated for the 1.0b ? or svn anytime soon? ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Dom creation
Does not work with the latest svn but it works with 1.0a. you gave me the same link :) i did try a newier svn first though just to check still no go. Aloyzas Rimeika wrote: Maybe this one will work :) http://www.aloyzas.lt/javascript/jquery/dom.js On 8/9/06, Jason Yeckel [EMAIL PROTECTED] wrote: http://www.aloyzas.lt/javascript/jquery/dom.js Will this be updated for the 1.0b ? or svn anytime soon? ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/