.live with AJAX problem

.live with AJAX problem

I have a table. Each row comes from a MySQL database and contains an anchor with the css class .block
If you click on one of these anchors, it will perform a AJAX $.get and respond with the content relevant to the specific row that was clicked.

This content is another table of database-driven content. In order to allow my user to re-order this content, each row contains a link for 'Up' and a link for 'Down'.
As an example, the 'Up' anchors have the class 'productsimageup' and when clicked, AJAX $.get is used to interrogate a php file which changes the order. The HTML response is the new table (the order has changed) and the old table is therefore replaced.

  1. $(document).ready(function(){
  2.     $('.productsimageup').live("click", function(event) {
  3.         event.preventDefault();
  4.             var url = $(this).attr("href");
  5.             $.get(url, function (resp) {
  6.                 $('#productimages').html(resp);
  7.             });
  8.        
  9.     });
  10. });

The problem I'm having is that it only works once. Clicking 'Up' immediately moves the row in question up one. However click again and event.preventDefault(); has no effect - it loads the page - the function is no longer bound. I thought 'live' would fix this, but no such luck...

Thanks,

spitfireweb











    • Topic Participants

    • ben