Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: Change default class name

Change default class name 2 years 2 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.

Re: Change default class name 2 years 2 months ago #85222

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4372
  • Thank you received: 830
  • Karma: 381
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.

Re: Change default class name 2 years 2 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.

Re: Change default class name 2 years 2 months ago #85257

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4372
  • Thank you received: 830
  • Karma: 381
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.

Re: Change default class name 2 years 2 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.

Re: Change default class name 2 years 2 months ago #85332

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4372
  • Thank you received: 830
  • Karma: 381
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.

Re: Change default class name 2 years 2 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.

Re: Change default class name 2 years 1 month 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.

Re: Change default class name 2 years 1 month ago #86504

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4372
  • Thank you received: 830
  • Karma: 381
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.

Re: Change default class name 2 years 1 month 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.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.117 seconds
Donation Image