Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Drag and drop fail when called via ajax

 
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.

 
author
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
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

 
You totally ruined the moon. You're gonna hafta pay for that you know. This tiny ad agrees:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic