[jQuery] Functions from xml parsed document

[jQuery] Functions from xml parsed document


Hi one and all,
I'm loading a page from an xml file, no problems works fine; below is what
is output to give a better understand of what im trying to do...
<div class="product">
<\img src=blah1.jpg />
<div class thumbs><img1 /><img2 /></div>
The plan is, when someone clicks on a thumbnail, it get displayed in the
main image.
If i hard code some values in the html (rather than parse from xml)
thumbnail / display function works, the source updates, all good.
However, when I parse from the xml file, clicking on the thumbnails does
nothing.
//Parse xml file
$(document).ready(function() {
$.get('bedroom.xml', function(data) {
$('#main').empty();
        var $html;
    $(data).find('product').each(function() {
var $product = $(this);
    $html = '<div class="product">';
    var $id = $product.find('id').text();
    var $name = $product.find('name').text();
$html += '<h2>' + $name + '</h2><br /><br />';
    $html += '<\img src="'+ $product.find('source').text() + '" />';
    var $thumbs = $product.find('thumbnails');
    if($thumbs.length)
    {
        $html += '<div class="thumbs">';
        $thumbs.find('thumb').each(function() {
    $html += '<\img src="' + $(this).text() + '" />';
        });
        $html += '</div>';
}
    $html += '' + $product.find('description').text();
    $html += '<br /><br />';
    $html += 'Prices from: &pound;' + $product.find('price').text();
    $html += '<br /><br />';
    $html += '
<\img style="border:none" src="images/add.jpg" width="100px" height="20px"
/> '
            
$html += '</div><div class="spacer"></div>';
            
});
    $('#main').html($html);
    $('.product').dropShadow();
});
    
});
//Thumbnail swap
$(document).ready(function() {
$('.thumbs img').click(function() {
var scr = $(this).attr('src').replace("thumbs/","");
$(this).parents('.product').children('img').attr('src',scr);
});
});
Can someone please help me figure out why its not working? (ignore the <\img
in the code, ive only put the slashs in to delimit the html for this
message)
Thanks
Rich
--
View this message in context: http://www.nabble.com/Functions-from-xml-parsed-document-tp16369996s27240p16369996.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.