Change default class name

  • TwentyTwo
  • TwentyTwo's Avatar Topic Author
  • Visitor
  • Visitor
4 years 6 months ago #85211 by TwentyTwo
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!

Please Log in to join the conversation.

More
4 years 6 months ago #85222 by tpartner
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.

Please Log in to join the conversation.

  • TwentyTwo
  • TwentyTwo's Avatar Topic Author
  • Visitor
  • Visitor
4 years 6 months ago #85250 by TwentyTwo
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?

Please Log in to join the conversation.

More
4 years 6 months ago #85257 by tpartner
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.

Please Log in to join the conversation.

  • TwentyTwo
  • TwentyTwo's Avatar Topic Author
  • Visitor
  • Visitor
4 years 6 months ago #85330 by TwentyTwo
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.

Please Log in to join the conversation.

More
4 years 6 months ago #85332 by tpartner
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.

Please Log in to join the conversation.

  • TwentyTwo
  • TwentyTwo's Avatar Topic Author
  • Visitor
  • Visitor
4 years 6 months ago #85333 by TwentyTwo
Great! I am going to play around with this later, this should work!!
Thanks again!!

Please Log in to join the conversation.

  • TwentyTwo
  • TwentyTwo's Avatar Topic Author
  • Visitor
  • Visitor
4 years 5 months ago #86500 by TwentyTwo
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?

Please Log in to join the conversation.

More
4 years 5 months ago #86504 by tpartner
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.

Please Log in to join the conversation.

  • TwentyTwo
  • TwentyTwo's Avatar Topic Author
  • Visitor
  • Visitor
4 years 5 months ago #86516 by TwentyTwo
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!

Please Log in to join the conversation.