working with .load()
working with .load()
hi
i'm trying to create a min-shopping cart (as a way of learning jquery)
when the page first loads it has the list of items (picture, title, price and buy link)
to add item into the shopping basket i use this code:
- $(".items a").click(function(e){
e.preventDefault();
$("tr#a").after('<tr><td class="quantity"><p>' + $(this).parents('.items').find("h3").text() + '</p></td><td class="quantity"><input type="text" value="1" /></td><td class="unit_price"><input class="price" value="'+ $(this).parents('.items').find(".price span").text() +'" disabled="disabled" type="text" /></td><td><input class="here" type="text" disabled="disabled" value="'+ $(this).parents('.items').find(".price span").text() +'" /></td><td class="delete"><img src="http://www.biocentury.com/archives/Images/icon_delete.gif" /></td></tr>');
plus more code for calculations and so on.
now i want to be able to filter the items (the produces i'm working with are music albums) - so i want users to filter, only rock, hip-hop and so on - for this I am using this code:
- $("#option").click(function(e){
e.preventDefault();
$("#base").empty().load("index.php?gen=hip-hop #base");
})
i think i will need to work on this a bit more - BUT for this case it works
the problem starts here, when i empty() the existing product list, and add new set of (picture, title, price and buy link) , my clicking function you see at the top (and all the other functions) do not work (the clicking functions do target the anchors that i am loading above)
it could be the idea that items need to be in the dom before the dom ready() starts, but would you be able to recommend me any way around this problem
i really hope that i am clear enough
thanks a lot
aurel