Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Drag and drop fail when called via ajax

 
sukbir frwa
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,
I have two pages with the similar codes. One is here http://183.78.169.53/tm/addTyreSwap1.php in this page you have select the vehicle via the drop down list then a number of tyre will appear via the ajax call. The problem is that both the draggable and droppable is attached to it but is not working. On the other hand I have another page http://183.78.169.53/tm/getTyreLayoutDetails1.php?l=3 here which directly generate the tyre layout and both drag n drop works perfects fine. Both are using the same codes. Only one is via ajax. Any idea why it fails in ajax? To my suprise both pages have the same coding. A snippet of codes is below. But when I go through the output the first page is <span class=“droppable”> and second generates this <span class=“droppable ui-droppable”>. My guess for the solution is reassign the drag and drop the new data after ajax call which is where I am stuck any idea? I do not know how to use the live function here.

 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you calling the code that initializes the click events after you add the content to the page?

I am guessing you are registering the draggables and such before the elements they are added to the page. They do not magically hook themselves up when you dynamically add them.

Eric
 
sukbir frwa
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Eric,
No I am not doing after added the elements to the page. Here is where I stuck how to assign the draggable and droppable again to item. I guess is there ready because back in my php code I have put them but is not functioning either. Any help please?

Eric Pascarello wrote:Are you calling the code that initializes the click events after you add the content to the page?

I am guessing you are registering the draggables and such before the elements they are added to the page. They do not magically hook themselves up when you dynamically add them.

Eric
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are not doing it, you need to do it.

On the success callback, call the JavaScript code to initialize it.

Eric
 
sukbir frwa
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Eric,
Can you show me some snippet of code on how to achieve this?

I have tried this but fail too.





Eric Pascarello wrote:If you are not doing it, you need to do it.

On the success callback, call the JavaScript code to initialize it.

Eric
 
sukbir frwa
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Eric,
I am doing something like this is it ok.



sukbir frwa wrote:Dear Eric,
Can you show me some snippet of code on how to achieve this?

I have tried this but fail too.





Eric Pascarello wrote:If you are not doing it, you need to do it.

On the success callback, call the JavaScript code to initialize it.

Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic