Welcome, Guest
Username: Password: Remember me

TOPIC: Change default class name

Change default class name 3 years 5 months ago #85211

  • TwentyTwo
  • TwentyTwo's Avatar
I am trying to create a new template based on - jquery mobile.

Is it possible to change the default css class per question.
So for example I have a normal list (radio) question.

How could I override the default class for the answers.


Can I add in some script to replace the:
input class="radio"

just to:
input class="radio-custom"

Thanks!
The administrator has disabled public write access.

Change default class name 3 years 5 months ago #85222

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5415
  • Thank you received: 1154
  • Karma: 479
Add the following to the end of template.js:
 
	$(document).ready(function(){
 
		$('input.radio').addClass('radio-custom').removeClass('radio');
	});
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Change default class name 3 years 5 months ago #85250

  • TwentyTwo
  • TwentyTwo's Avatar
thanks for the answer!

Is there a way to do this per question itself as well?
To have different layouts for different list radio questions?
The administrator has disabled public write access.

Change default class name 3 years 5 months ago #85257

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5415
  • Thank you received: 1154
  • Karma: 479
For that, I think you can just use the question IDs as selectors. For example, if your question ID is 123, use this:
#question123
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Change default class name 3 years 5 months ago #85330

  • TwentyTwo
  • TwentyTwo's Avatar
Thanks Tony,
Yes this is how I indeed use it when just changing the css for a particular question.

My problem however is that I really want to change the class, because I am trying to have the jquery-mobile working.
It is not only the style that needs to change but with the class name js functions are referring to these.
The administrator has disabled public write access.

Change default class name 3 years 5 months ago #85332

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5415
  • Thank you received: 1154
  • Karma: 479
Sure, I understand what you are trying to do. Just use the unique question IDs in your selectors:
	$(document).ready(function(){
 
		$('#question123 input.radio').addClass('radio-custom').removeClass('radio');
	});
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Change default class name 3 years 5 months ago #85333

  • TwentyTwo
  • TwentyTwo's Avatar
Great! I am going to play around with this later, this should work!!
Thanks again!!
The administrator has disabled public write access.

Change default class name 3 years 4 months ago #86500

  • TwentyTwo
  • TwentyTwo's Avatar
I have tried some more but unfortunately I don't get it working.
Not sure if I miss something.

By adding the add class / remove class I do see something is changing, because I don't see my answers anymore.
However when checking the source I don't see the class is renamed.

I have also tried to change the class of the answer instead of the question but that gives the same result.

See hereby a test survey: example

Any idea what I am missing?
The administrator has disabled public write access.

Change default class name 3 years 4 months ago #86504

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5415
  • Thank you received: 1154
  • Karma: 479
You will not see the class changed when "viewing the source" because that is the source when the page loads, not what it is after JavaScript manipulation. To see the dynamic source use a tool like Firebug for Firefox.

Your Demo survey is not accessible.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Change default class name 3 years 4 months ago #86516

  • TwentyTwo
  • TwentyTwo's Avatar
Ah yes indeed!
All perfect, this addClass - removeClass is now working!

I will continue with the jquery mobile investigation and will share this when succesfully implemented.

like always thanks for your great help!
The administrator has disabled public write access.

Change default class name 3 years 4 months ago #86520

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5415
  • Thank you received: 1154
  • Karma: 479
And thank you for your donation :)
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Change default class name 3 years 4 months ago #86558

  • Mazi
  • Mazi's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5841
  • Thank you received: 347
  • Karma: 261
Are you trying to create a special template for mobile devices?

Some smartphone/tablet optimized templates for Limesurvey already exist at www.limesurvey-templates.com/smarthphone...-optimized-c-28.html

Can you post another test link so we can have a look how the template looks like?

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

Change default class name 3 years 4 months ago #86578

  • TwentyTwo
  • TwentyTwo's Avatar
Hi Mazi,

I am trying to create a device agnostic template.
Not only to have the template design the same but also the question layout.
So the same and look independent from the browser or device a person is using.
The basic form elements in jquery mobile should work nicely for both desktop as mobile.

As soon as I achieved more I make sure to share this!
The administrator has disabled public write access.

Change default class name 3 years 3 months ago #87044

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 8229
  • Thank you received: 1122
  • Karma: 333
You can get some inspiration here :https://gitorious.org/skeletonquest

Tested in a lot of "browser screen"
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.479 seconds