function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Carl-JesperCarl-Jesper 

Not possible to pass dynamic variable into javascript at commandLink oncomplete

I'm want to pass a dynamically set variable "f" which serves as an element id into a javascript to be able to recolor the item. 

 

However, I get the following error at compile time: 

Save error: Unknown property 'OpportunityStandardController.f' 

 

Is this a limitation or have I misunderstood anything?

 

<apex:repeat var="f" value="{!families}">
<li>
<span>
<apex:commandLink value=""
action="{!runSearch}"
rerender="results,debug"
oncomplete="doIt({!f});">
<apex:param name="name" value="" />
<apex:param name="onlySellable" value="" />
<apex:param name="family" value="{!f}" />
<span id="{!f}" name="nameAllItems">{!f}</span>
</apex:commandLink>
</span>
</li>
</apex:repeat>

 

<script>

function doIt(string anId){
var items = document.getElementsByName("nameAllItems");
for(var i = 0; i < items.length; i++)
{
items[i].setAttribute("class", "");
}
document.getElementById(anId).setAttribute("class", "current");
}
</script>