- Posts: 962
- Thank you received: 216
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
- Topic Author
- Offline
- Official LimeSurvey Partner
Less
More
9 years 8 months ago #110598
by tammo
Tammo ter Hark at Respondage
For Limesurvey reporting, education and customized themes
respondage.nl
Empty div and span generated by core was created 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?
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13907
- Thank you received: 2546
9 years 8 months ago #110602
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
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
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 service on demand , plugin development .
I don't answer to private message.
The following user(s) said Thank You: tammo, Ben_V
The topic has been locked.
- tammo
- Topic Author
- Offline
- Official LimeSurvey Partner
Less
More
- Posts: 962
- Thank you received: 216
9 years 8 months ago #110610
by tammo
Tammo ter Hark at Respondage
For Limesurvey reporting, education and customized themes
respondage.nl
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
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13907
- Thank you received: 2546
9 years 8 months ago #110611
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
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 :
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 :
It's a template issue: not a LimeSUrvey issue : limesurvey just add *, nothing else.
We have a lot of problem elsewhere ... please : patch core
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>","")}
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 service on demand , plugin development .
I don't answer to private message.
The following user(s) said Thank You: tpartner
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3690
9 years 8 months ago #110629
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
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).
.
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13907
- Thank you received: 2546
9 years 8 months ago #110635
by DenisChenu
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 service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Empty div and span generated by core
Thanks,tpartner wrote: Yes Denis, great tip about putting qualifiers around elements in the template files.
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 service on demand , plugin development .
I don't answer to private message.
The topic has been locked.