You need to sign in to do that
Don't have an account?

Dependant Picklist Does Not Render Class Attribute
I am trying to add a Class to a Input Field in Visual Force but when the page is rendered it removes the styleClass Attribute. This inputField is a dependant Picklist.
Below is my VF Code
<apex:inputField value="{!configTaskToUpdate.Config_Category__c}" styleClass="form-control" id="thecategory"/>
i have tried adding the the code to a div tag around it but it comes out akward
I have also tried adding it to the the field by jQuery as below but that doesnt work either
Anyone have this issue and or found a workaround or is SF working on it?
Below is my VF Code
<apex:inputField value="{!configTaskToUpdate.Config_Category__c}" styleClass="form-control" id="thecategory"/>
i have tried adding the the code to a div tag around it but it comes out akward
I have also tried adding it to the the field by jQuery as below but that doesnt work either
$(document).ready(function() { $(function() { $("#{!$Component.theform.thecategory}").addClass("form-control"); console.log('added the form-control class'); }); });
Anyone have this issue and or found a workaround or is SF working on it?
In case of Jquery in salesforce, there is a different approach to identify the components based on ids in case it is a visualforce tag (not standard html tag).
you need to refer as:
$('[id*=thecategory]').,
for more info on using jQuery, refer to below link:
https://developer.salesforce.com/page/Developing_Apps_with_jQueryv
And one more thing., in Visualforce pages, once the page is rerendered upon an action, jQuery looses its scope of the compoenent., I can suggest you to use .live function in jQuery in case you are using 1.7 version or earlier.
Thanks,
Balaji
All Answers
Got it, just try these steps:
1. Create a javascript function, put the
$("#{!$Component.theform.thecategory}").addClass("form-control");
code in this function.
2. I think u r using some button or action function to rerender the page. Is it right ?
on action function or button put a attribute oncomplete=YourJavscriptFunction
like; <apex:actionfunction name="myfun" action="{!BlahBlah}" oncomplete="YourJavscriptFunction">
:::======================================================================:::
Qusetion Solved ? then mark as best answer to make helpful to others .....
In case of Jquery in salesforce, there is a different approach to identify the components based on ids in case it is a visualforce tag (not standard html tag).
you need to refer as:
$('[id*=thecategory]').,
for more info on using jQuery, refer to below link:
https://developer.salesforce.com/page/Developing_Apps_with_jQueryv
And one more thing., in Visualforce pages, once the page is rerendered upon an action, jQuery looses its scope of the compoenent., I can suggest you to use .live function in jQuery in case you are using 1.7 version or earlier.
Thanks,
Balaji