5

I have a simple D&D script as you can see here:

http://demo.superdit.com/jquery/dragdrop_cart/

Now its working Great until Im trying to add the products with AJAX (After the page loaded)

Here is the AJAX call (Regular AJAX)

$.ajax({
              url: "Search.php",
              dataType: 'json',
              type: 'GET',
              data: "ebayq="+value,
              success: function(data){
                globalRequest = 0;
                resultContainer2.fadeOut('fast', function() {
                    resultContainer2.html('');

              var html2 = [];


    for (var i = 0; i < items.length; ++i)  
  {

html2 += '<label class="title"><a href="'+viewitem+'" target="_blank">'+title+'</a></label>';html2 += '<img src="'+pic+'">';
        html2 += ' <label class="price">New Price: '+myprice+'</label>';
        html2 += '</div>';
        resultContainer2.append(html2);

  }

i guess because this elements are loaded after the page load and it doesn't recognize them as a draggable items..

is there Any way to make this AJAX items draggable??

Thank you very much!

Eran Levi
  • 877
  • 2
  • 12
  • 31

1 Answers1

4

Run $('your-selector').draggable() again, in your AJAX success method.

Unless you can find a way to make Jquery.on or Jquery.live to work with JqueryUI.Draggable.

MichaelS
  • 7,023
  • 10
  • 51
  • 75
  • 1
    Thank you!! Here is A Way to use draggable in jquery.live: http://stackoverflow.com/questions/1805210/jquery-drag-and-drop-using-live-events – Eran Levi Feb 02 '13 at 13:38