Skip to content
This repository was archived by the owner on Nov 21, 2019. It is now read-only.

toArray() custom attribute #66

Open
thekrotek opened this issue Feb 8, 2017 · 0 comments
Open

toArray() custom attribute #66

thekrotek opened this issue Feb 8, 2017 · 0 comments

Comments

@thekrotek
Copy link

thekrotek commented Feb 8, 2017

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))
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant