Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Trying to check if child class contains question ID

  • Omti90
  • Omti90's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
2 years 11 months ago #215641 by Omti90
Hello everyone,

I'm currently modding the card-sort template and I'm currently stalled.

[img


I'm trying to sort the "cards" above into the columns below. The user is supposed to be able to drag each card into a column once. I'm currently trying to figure out how to check if a column already contains the "card".

Each card has a question id somewhere in their class name, so I'm trying to search for the string in the class names of the children of the column class. I've been googleing a bit and found this suggestion: stackoverflow.com/questions/3914900/jque...te-contain-substring

I've been trying to realise this so:
Code:
if($(this).closest('items-end-inner').parent().className.indexOf('sgqa') > -1)
{
//do stuff
}
This always returns false. Even if I turn this around with <0 it still always returns false. I'm not sure what I'm doing wrong here. As far as I understand "this" is the class my card is dropped into. I'm trying to make sure it's actually the right one with the closest() method. (originally did it without, but no difference) Then I grab the parent of that and then it should hopefully search in the children for the string.

Maybe something that's complicating this is that the the classes I'm trying to search are not diret children of the parent class, but second degree children. That still doesn't explain why it would always return false.
The topic has been locked.
More
2 years 11 months ago #215691 by fiedsch
I thinking is the way jQuery works. .length  might help you to see if the query (I.e. $(…) or jQuery()) yielded a collection of length greater than 0.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 11 months ago #215701 by tpartner
This is a jQuery discussion, not directly related to LimeSurvey.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: DenisChenu
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose