This task has been canceled!


Created by
pond87 52 about 24 days ago

jQuery Object / data attribute access issue

I am trying to troubleshoot some jQuery code and added this:


and all the alert returns is undefined. So I try this:


and I get the expected DOM element in the alert

<li class="dd-item dd3-item" data-type="parent" data-id="6" data-new_record="false">

I am no JS or jQuery expert by any means and I am at a loss why I can't get the parent data value from this.


Did some digging to find where this is set:

this.dragEl = $(document.createElement(this.options.listNodeName)).addClass(this.options.listClass + ' ' + this.options.dragClass);

For context this is the Nestable2 ( plugin. The li is cloned then destroyed from the DOM. The user is now dragging this around to drop on a new home location. I am trying to add some user feedback so that when you try and drop this on a 'not allowed' location the default blue placeholder dropzone div that gets added is red. It seems to be an easy patch once I figure out how to read that data attribute on the item being moved.

Added the code in question to a JS fiddle (line 1041):

See task infos

Solutions (1)


ourjourney 64 about 21 days ago
10 mBCH
Accepted solution