Droppable dynamic tab

Droppable dynamic tab

Hi All,

I'm very new to jQuery and am looking to use it to do some somewhat advanced UI features on our corporate web portal.  I am loading a tab panel dynamically and would like to have the tabs be droppable receivers of a draggable component.  I load the tabs, set them as droppable and then set the draggable component however the tabs do not register as being dropped upon by the draggable.  If I create a static tab it works as intended.  I'm sure I'm doing something stupid so if anyone could shed some light I'd appreciate it.  Below is my rough sample of what I'm trying to do:
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  4. <title>JQuery Test</title>
  5. <link type="text/css" href="css/smoothness/jquery-ui-1.8rc3.custom.css" rel="stylesheet" />
  6. <style type="text/css">
  7. #tabs li .ui-icon-close { float: left; margin: 0.4em 0.2em 0 0; cursor: pointer; }
  8. #add_tab { cursor: pointer; }
  9. </style>
  10. <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
  11. <script type="text/javascript" src="js/jquery-ui-1.8rc3.custom.min.js"></script>
  12. <script type="text/javascript">
  13. var droppable = function(event, ui) {
  14. alert('dropped on tab ' + ui);
  15. }
  16. $(function(){
  17. var $tab_indx = 0;
  18. var $tabs = $('#tabs').tabs({
  19. tabTemplate: '<li class="droppable"><a href="#{href}">#{label}</a> <span class="ui-icon ui-icon-close">Remove Tab</span></li>',
  20. ajaxOptions: {
  21. error: function(xhr, status, index, anchor) {
  22. $(anchor.hash).html("Oops.");
  23. }
  24. },
  25. load: function(event, ui) { alert('loading'); }
  26. });
  27. loadTabs();

  28. $('li.droppable').droppable({
  29. drop: droppable
  30. });
  31. $('#draggable').draggable({
  32. revert: 'invalid'
  33. });
  34. function addTab(jsonTabData) {
  35. var tab_title = jsonTabData.name;
  36. var tab_url = jsonTabData.url;
  37. $tabs.tabs('add', tab_url, tab_title);
  38. if (!jsonTabData.isEnabled) {
  39. $tabs.tabs('disable', $tab_indx);
  40. }
  41. $tab_indx++;
  42. }
  43. function loadTabs() {
  44. $.getJSON('http://localhost:65080/jquery_tests/gettabs.php?callback=?', function(data) {
  45. $.each(data, function() {
  46. addTab(this);
  47.   });
  48. });
  49. }
  50. });
  51. </script>
  52. </head>
  53. <body>
  54. <div id="container">
  55. <div id="tabs">
  56. <ul/>
  57. </div>
  58. <div id="draggable" class="ui-state-highlight" style="width: 200px;">
  59. <h4>dropping item</h4>
  60. </div>
  61. </div>
  62. </body>
  63. </html>

Thanks!