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


    auswahl3.html
    test_town.js are appendend as text.

    Code
  • 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.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!