File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Drag and drop fail when called via ajax Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Drag and drop fail when called via ajax" Watch "Drag and drop fail when called via ajax" New topic
Author

Drag and drop fail when called via ajax

sukbir frwa
Greenhorn

Joined: May 12, 2011
Posts: 14
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
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

Joined: May 12, 2011
Posts: 14
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
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

Joined: May 12, 2011
Posts: 14
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

Joined: May 12, 2011
Posts: 14
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Drag and drop fail when called via ajax