dragging and droping of divs

  • Hello I have done a script, which can load names in divs, which are then showed on the screen. This divs are draggable in boxex in the middle.

    I am wondering why the divs, that are created from the JSON-list are immadiately kicked out from the boxex, while the divs, that are created in the html-code(town1-5) stay in the boxex.

    Both should have same class. The function (update_towns) is in line 309. This creates the divs.

    Thank you in advance for helping

    test_town.js are appendend as text.



    • test_town.txt

      (2,22 kB, 2 Mal heruntergeladen, zuletzt: )
    • auswahl3.txt

      (12,94 kB, 2 Mal heruntergeladen, zuletzt: )
  • Ajax works asynchronously, i. e. the request is sent to the server and it takes a short time until the response is received. At that time initialisation for drag&drop (by calling draggable() and droppable())is already done and doesn't come into effect for the boxes being created by the ajax response.

    Place the initialisation inside the ajax callback and it should work.