Reputation: 3999
I have the following code in my view:
<apex:commandLink data-role="button" action="{!someAction}">
<apex:param name="someVar" value="someVarVal">
</apex:commandLink>
The code does not work because commandLink does not take the "data-role" attribute.
How can I pass a parameter like I am with the second line, but also have an attribute like "data-role" on the rendered link?
Upvotes: 2
Views: 593
Reputation: 1
you can just use html pass through syntax :
html-attribute=value
for example
html-class="toto" will output class="toto"
Upvotes: 0
Reputation: 8255
I've never found a way to put extra attributes into VF tags, your best bet IMO would be to add some javascript which runs on page load and then use JQuery's .attr()
method to add the attribute to the component.
Something like the following (assuming you've included jquery through a static resource)
<apex:commandLink styleClass="myLink" action="{!someAction}">
<apex:param name="someVar" value="someVarVal"/>
</apex:commandLink>
<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function(){
jQuery(".myLink").attr("data-role", "button");
});
<script>
You'll notice I've used a class instead of ID here, this is simply because SFDC generated IDs include symbols which need to be escaped for use with jQuery, and I find this is just the easier and cleaner solution to use (albeit probably slightly slower).
Upvotes: 2