Jump to content
Search Community

Inheritable / Dynamic Draggable assignment in conjunction with jQuery .on()

shaunhurley test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hi Folks,

 

Am trying to determine if there is any way to use Draggable in conjunction with jQuery's .on() method, or to achieve a similar result, such that any dynamically created element of a given class under a parent object will inherit the Draggable configuration.

 

jQuery doc -> http://api.jquery.com/on/

 

I saw a previous conversation thread

that referenced an add-in called waitUntilExists which has this approximate effect, but only for a single names element at a time(plus looks like it may no longer work since jQuery 3...)

 

Any thoughts would be appreciated!

Link to comment
Share on other sites

Hi @shaunhurley

 

Do you have an example of what you're trying to do? There's a MutationObserver that can be used to detect when the DOM changes, but I really don't see the point of using something like that. Elements don't magically show up in the DOM. Some action is necessary to create and insert an element, so whenever that action takes place, create your draggable.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

1 hour ago, OSUblake said:

Hi @shaunhurley

 

Do you have an example of what you're trying to do? There's a MutationObserver that can be used to detect when the DOM changes, but I really don't see the point of using something like that. Elements don't magically show up in the DOM. Some action is necessary to create and insert an element, so whenever that action takes place, create your draggable.

 

Thanks @OSUblake, you are absolutely correct, that is exactly what I ended up doing.  I found (and had a brief look at MutationObservers, but ended up constructing them individually.  Basically I was working within the constraints of some existing code, and being lazy :)

 

Appreciate the respone!

 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...