sm planet

#115 Class request

Posted in ‘Easycheckbox’

This is a public ticket. Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.
Tuesday, 01 September 2015 05:51 UTC Eliel Gonzalez Silverio
 Hi guys,

I have a question, is it possible and easy to add a class to the selected input field?

Thanks.
Tuesday, 01 September 2015 09:07 UTC Maja Možina Mlinar
Hi Eliel,

Do you mean only when page is created or on the go - so when user selects checkbox.

Well, in both case it's possible and not hard to do it.

Open plugins/vmcustom/easycheckbox/easycheckbox.php

If you want to add class by default - so when page is created, find
<input style="float: left; margin-right:5px;"
and add class=SOMECLASS". It's three times in the code.

If you want replace classes on the go, you need to do it with javascript. Find
function setCheckboxJavascript () {
and after
Virtuemart.setproducttype(form, id);
add this:
				jQuery(checkbox).parents(".product-field-display").find("input:checkbox").each(function() {
					if (jQuery(this).prop("checked") == true) jQuery(this).attr("class", "checked");
					else jQuery(this).attr("class", "");
				});
Best Regards,
Maja
Wednesday, 02 September 2015 04:40 UTC Eliel Gonzalez Silverio
Hi Maja, actually I was looking both.

I added the javascript. It works great, but when the page loads the class is not added until I clicked again the checkbox.

I'm using #Checked parameter.

Thanks
Wednesday, 02 September 2015 05:36 UTC Maja Možina Mlinar
Hi Eliel,

Try this - find
$checked = 'checked';
and replace it with
$checked = 'checked class="checked"';


Best Regards,
Maja
Sunday, 06 September 2015 00:40 UTC Eliel Gonzalez Silverio
Thanks, It worked... is it posible to do the same for the span next to input field?