I have been playing around with the sortable() functionality and I have got it working fine on static DB results, however I have noticed that I can't get it to work on AJAX-generated DB results. I feel it has something to do with how I call the sortable() function within the $(document).ready(function() however I am not 100% sure. I have searched this forum and other forums to see if anyone else has this problem but I haven't found anything similar yet, so here's my attempt to describe my problem:
I have a MySQL database called 'db_objects' which contains 1 table:
INSERT INTO `tbl_objects` (`obj_id`, `obj_name`, `obj_type`) VALUES
(1, 'Sam', 1),
(2, 'John', 1),
(3, 'Tom', 1),
(4, 'Bob', 1),
(5, 'Fluffy', 2),
(6, 'Paws', 2),
(7, 'Kitty', 2),
(8, 'Tibbles', 2),
(9, 'Mr. Meow', 2);
Now, I have a HTML page where I want to view the results on this table based on a drop-down box which filters by the obj_type column (1 = human names, 2 = feline names):
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html xmlns='http://www.w3.org/1999/xhtml'><head><title>SORTABLE EXAMPLE</title>
Now, if you can get this working you will notice that the sortable() functionality does not work. As I mentioned before, I think it has something to do with the fact that the DB results are generated on-the-fly by AJAX, so trying to declare/call the sortable() functionality in the $(document).ready(function() won't work, i.e.
$(document).ready(function() {
//CALL SORTABLE FUNCTIONALITY
$('#ul_sortable').sortable();
});
I'm not sure how to get around this - does anyone have any suggestions?