thank you immensely for all your help. I'll start rewriting the accordion code 
in a day or so.
-Jim

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Jake McGraw
Sent: Tuesday, March 06, 2007 3:30 PM
To: jQuery Discussion.
Subject: Re: [jQuery] rewriting generic ajax jQuery style


Jim, you can use the siblings() exactly as you put in your code, the only thing 
you should watch out for is siblings() will return a group of jQuery objects, 
which in your case doesn't matter as item_id only has a single sibling, 
item_name. When you chain text() to a group of jQuery objects, only the first 
jQuery object returns its text. I'm not up on performance issues with jQuery, 
like I said before, there are a couple of ways of doing this, and you typically 
(in my experience) won't see performance differences between methods (say using 
XPath instead of CSS or find()) until you start dealing with a large (300+) 
dataset (at which point I'd forgo ajax and just deliver using html). 

- jake


On 3/6/07, Jim Wharton < [EMAIL PROTECTED]> wrote: 

Ok, here's another question.... I've got this code working:

$(document).ready(function() {
                $('#resultcontainer').accordion();
                                $("dt").click(function(){ 
                                        idsource = $(this).attr("id");
                                        $.ajax({
                                           type: "GET",
                                           url: " getItems.php",
                                           data: {cat_id: idsource},
                                           dataType: "xml",
                                           success: function(xml){ 
                                              //build a table from xml results.
                                              var output = 
'<table><thead><tr><th>Items Available</th></tr></thead><tbody>'; 
                                              //create rows for each result.
                                              $("item_id", xml).each(
                                                 function() { 
                                                                var linkId = 
$(this).text();
                                                    output += '<tr>';
                                                                output += 
'<td>'+$(this).text()+'</td>'; 
                                                    output += '<td><a 
href="itemdetail.php?item_id='+linkId+'" 
>'+$(this).siblings().text()+'</a></td>';
                                                    output += '</tr>'; 
                                                 }
                                              )
                                              output += '</tbody></table>';
                                              
$('#itemtable'+idsource).html(output); 
                                           }
                                        })
                                })
                                });

I just looked for a "nextSibling" style analouge in jQuery. Would it be more 
benificial to change the node I am getting out of the XML file and grab both 
its children? or is this method ok?. Which one would be faster? Selecting two 
children? or selecting siblings? 

Thanks,
-Jim


.-*** Message Scanned by Alachua County McAfee Webshield Appliance ***-.
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/





  _____  

.-=== Message Scanned by Alachua County McAfee Webshield Appliance ===-. 





.-*** Message Scanned by Alachua County McAfee Webshield Appliance ***-.
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to