Attention:

Support Rules and Guidelines
Before you post your support topic, please remember to:
  • Read the support forum rules.
  • Check the wiki and use search to see if your problem can be answered there first.
  • Link your board please, and make sure that the problem on your board is visible to guests or provide a test account.
  • Do not post Board Wrappers and CSS unless requested. With a board link, this is not necessary.
  • Be as descriptive as you can and use as many details as possible when describing your problem.
  • Please briefly mark any links to forums that may not be work-safe.
This will help ensure your support issue will be attended to in a quick and efficient manner.

  ClosedNew TopicNew Poll

 Hide Empty Fields in HTML Templates [SOLVED]
#
Hi! I was hoping someone might be able to help me. I'm switching from Black's CFS over to the HTML Templates. I'm trying to hide empty fields using the code from here.

But I realized this won't work because the empty fields will not default to N/A anymore, they are blank instead. Until a default value for empty fields is possibly implemented I was wondering if there was a script I could use that would act like the naremove script I had been using.

Basically I want to be able to hide or remove an entire class if the field is left empty.
PM
#
A simple method would be using the :empty selector in jquery. Something like (untested, of course):
CODE
$('.element:empty').remove();
PM
#
Thank you so much! This worked great!!

There was one field in my miniprofile that was set up like:
CODE
<div class="element"><!-- |field_#| --> years old</div>

So the class was technically not empty, so the script wouldn't work, but it's so much better than it looked before!!
PM
#
Ahh. In that case you would need an if-then statement to check the length of the field.
PM
#
Would you mind showing me an example of what that would look like? I know next to nothing about jquery http://files.b1.jcink.com/html/emoticons/unsure.gif

This post has been edited by croixbones: Nov 9 2016, 01:37 PM
PM
#
Actually, now that I think about it, why not set the field up like
CODE
<div class="check"><span class="amiemptyinside"><!-- |field_#| --></span> years old</div>


And then simply alter the previous script snippet to

CODE
$('.amiemptyinside:empty').parent().remove();


Shooould work? Maybe.
PM
#
IT DOES!!! Thank you so, so much!! You just solved so many hours of frustration for me!! http://files.b1.jcink.com/html/emoticons/biggrin.gif
PM
#
Hooray!
PM
#
This topic has been solved. If you need anymore help please post a new thread. Thanks for choosing Jcink services.

signature
email: admin@jcink.com :: blog: John C.
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:
Share this topic:
« Next Oldest | General Support | Next Newest »

Options ClosedNew TopicNew Poll