touch-dnd icon indicating copy to clipboard operation
touch-dnd copied to clipboard

toArray() custom attribute

Open thekrotek opened this issue 7 years ago • 0 comments

There's a little issue with toArray() method. If you use custom attribute like 'data-foobar' you always get an 'undefined' for every element and returned array is just a bunch of commas. Problem's with this line:

attrs.push($(this).prop(attr))

'data-foobar' is an attribute, not property. At least, that was in my case. I changed it to this:

attrs.push($(this).attr(attr))

and it started working properly. Might be worth looking into.

UPD:

In case you still have interest in your script, I ended up with this code:

if ($(this).attr(attr)) {
  attrs.push($(this).attr(attr))
}

thekrotek avatar Feb 08 '17 21:02 thekrotek