Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7505781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:01:44+00:00 2026-05-29T22:01:44+00:00

I create some elements on runtime (js) and make them draggable: function fillAttachmentsPerPage(pageNum) {

  • 0

I create some elements on runtime (js)
and make them draggable:

function fillAttachmentsPerPage(pageNum) {
    createAjaxRequest("Manager/GetAttachments", {
        'locationId': current_folder.attr('id'),
    }).done(function (res) {

        for (var i = 0; i < res.Attachments.length; i++) {

            attachmentDiv = '<div class=\"attachmentDiv ui-draggable\" id="'+ res.Attachments[i].AttachmentId +'" onmouseover=\"attachmentDiv_hover(this);\"'+
            'onmouseout=\"attachmentDiv_onmouseout(this);\">' +
'</div>​';

        }



         $( ".attachmentDiv" ).draggable({
        //    start: function(event, ui) { ... }
            revert: 'invalid',
            drag: function(event, ui) { console.log("dragging") }
        });


        $('a:has(ins)').droppable({
           drop: function(event, ui) {
           console.log($(this).parent())
           setCurrentAttachment(ui.draggable.attr("id"));
           UpdateAttachmentLocation(ui.draggable.attr("id"), $(this).parent().attr("id"))

          }
        });

    });
}


 $( ".attachmentDiv" ).draggable({
//    start: function(event, ui) { ... }
    revert: 'invalid',
    drag: function(event, ui) { console.log("dragging") }
});

It works great.

After I drop this element in on dragable element

I create the same elements again, but without the one dropped.

The above registration code is executed again, but yet the elements are not draggable.

Any idea why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T22:01:46+00:00Added an answer on May 29, 2026 at 10:01 pm

    Because the elements are being added once the page has loaded, you might need to use the jQuery .on method. However, I don’t believe the .draggable method works with .on.

    A way of getting around this is to extend jQuery using the code below:

    (function($) {
        $.fn.liveDraggable = function(opts) {
            this.on("mousemove", function() {
                $(this).draggable(opts);
            });
        };
    }(jQuery));
    

    You need to add it after you’ve loaded jQuery, but before you try and use it in your code. Then rather than using:

    $(".attachmentDiv").draggable
    

    You use:

    $(".attachmentDiv").liveDraggable
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've a JavaScript function in my page through which i make some elements in
I try to create some li elements in my XUL Application. Theres only the
I'm trying to create a list that some of the elements are defined and
Is it possible in xsd to create restriction based on elements of some type
I'm attempting to change RenderTargets at runtime, so I can draw some elements at
I'm a bit stumped with this. I would like to create some elements (using
In HTML5, some elements (like <section> and <article> ) create a new sectioning context
I'm trying to create a new annotation with which I'll do some runtime wiring,
I need to create some sort of a state for a bunch of elements
I'm trying to create some drop down elements with CSS and jquery. Here's what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.