Welcome to the LimeSurvey Community Forum

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

Empty div and span generated by core

  • tammo
  • tammo's Avatar Topic Author
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
10 years 5 months ago #110598 by tammo
Currently we are defining a Bootstrap based theme for Limesurvey (which we will gladly share with interested people here).

We ran into the problem that at several places in the generated HTML empty divs and spans are generated. For example: when you have a non-mandatory question and you do not want to display the question code nor the question number, the following HTML is generated.

For example:

<h3 class="panel-title">
<span class="text-danger"></span>
<span class="question-code">pops01</span>
<span class="question-text"><span class="question-number"></span>
<p>
Heeft u opvang thuis na de operatie?</p>
<p>
TEST</p>
</span>
</h3>

The problem is that when you want to position element very precise with padding/margin, these paddings/margins also show up when the elements are not there. For example: when a question is not-mandatory, the padding/margins that you declare for the class .text-danger still show up, because the empty element is generated.

We have tackled this with javascript, but this is actually bad practice: all empty HTML is still generated and transferred to be deleted later.

Would it be possible to change the code thus that empty divs and spans are not generated into the HTML?


Tammo ter Hark at Respondage
For Limesurvey reporting, education and customized themes
respondage.nl
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
10 years 5 months ago #110602 by DenisChenu
Replied by DenisChenu on topic Empty div and span generated by core
HI,

1st solution : use :empty css class : developer.mozilla.org/docs/Web/CSS/:empty
2nd : use EM to remove undeeded div and span git.sondages.pro/?p=skeletonquest.git/.g...5f8808f50;hb=HEAD#l8

Some empty div can not be removed : Javascrpt update it.

Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The following user(s) said Thank You: tammo, Ben_V
The topic has been locked.
  • tammo
  • tammo's Avatar Topic Author
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
10 years 5 months ago #110610 by tammo
Replied by tammo on topic Empty div and span generated by core
Hi Denis,

we did use Javascript and solved the problem, but still it is more elegant to build in a check if an element contains data and not render it when it does nor contain data. That way you avoid empty HTML which needs to be hidden by extra javascript.

Thanks for the :empty tip, I did not know that one.

Tammo


Tammo ter Hark at Respondage
For Limesurvey reporting, education and customized themes
respondage.nl
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
10 years 5 months ago #110611 by DenisChenu
Replied by DenisChenu on topic Empty div and span generated by core
But the <span class="text-danger"></span> is from your template, we don't use it.

For :
Code:
<span class="question-number"></span>
Code:
{if(!is_empty(QUESTION_NUMBER) or !is_empty(QUESTION_CODE),"<span class='qnumcode'>"+QUESTION_NUMBER+" "+QUESTION_CODE+"</span>","")}
It's not javascript : QUESTION_NUMBER and QUESTION_CODE are static value : then it's removed from HTML (if survey setings disable show).

Like the :
Code:
{if(!is_empty(QUESTION_MANDATORY),"<span class='asterisk'>"+QUESTION_MANDATORY+"</span>","")}

It's a template issue: not a LimeSUrvey issue : limesurvey just add *, nothing else.

We have a lot of problem elsewhere ... please : patch core ;)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The following user(s) said Thank You: tpartner
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 5 months ago #110629 by tpartner
Replied by tpartner on topic Empty div and span generated by core
Yes Denis, great tip about putting qualifiers around elements in the template files.

Note that :empty does not work in IE8 and earlier (if anyone cares).


.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
10 years 5 months ago #110635 by DenisChenu
Replied by DenisChenu on topic Empty div and span generated by core

tpartner wrote: Yes Denis, great tip about putting qualifiers around elements in the template files.

Thanks,

The only potential issue is : "More memory for PHP". Think using EM use a lot of memory, we really need to work on cache for templating and survey start.

Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose