JQuery UI draggable not working with AJAX

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

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

Now it works fine until Im trying to add products with AJAX (after loading the page)

Here is an 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 think because these elements load after the page loads and do not recognize them as draggable elements.

Is there a way to make these AJAX elements draggable ??

Many thanks!

+5
source share
1 answer

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

If you can not find a way to do Jquery.onor Jquery.liveto work with JqueryUI.Draggable.

+4
source

All Articles