I have a flexrepeater and the instance is a view with a just 1 button. I have an array of strings called "issues". The instances for the flexrepeater are created dynamically in script using the "issues" array. Each instance has 2 properties - issue, index. The button text is bound to issue. What I am trying to do is apply class to the clicked button (thick border on the button to show the user the current active button) by binding to the classes property of style of the button. When the user clicks on lets say button 5 I am able to get the index of that button but how do let other buttons know that the current button is 5? I tried message handler between the button and the parent (flexrepeater) and the flexrepeater knows which button was clicked but I am not able to let other buttons know.
My first thought would be to create a memory tag that's holds a value set by the buttons.
I.e.
Button 1 selected:
Memory tag = 1
Class = x if memory tag == 1
Button 2 selected:
Memory tag = 2
Class = x if memory tag == 2
Etc
Not with tags, tags are gateway scoped and this is clearly session-specific.
Use custom properties on the repeater itself, and bidirectional parameters.
Though I'm not sure I understand what you're trying to do...
That has the problem that it will be shared by any other instance of the Perspective application running on another device. Great confustion may result.
Instead, use the view's or the flex repeater's custom properties to create a variable to share the current active button number.
I assumed that was the intention but definitely a good point to bring up!
How do we share the flex repeaters custom property with the instances?
Pass them as parameters. And make those parameters output AND input so they can send back data.
I was thinking of a message handler from the instance to the flex repeater and one from the flex repeater to all the instances, but I don't know if that is a bit overkill
I am not sure if this this is the best solution but this worked for me. This is how I worked.
- Created a customer property on the flex repeater called current_index
- On the flex instance (basically just a button) when user clicked then using message handler send message to update the current_index in step 1 above
- Then added a onChange script on current_index from step 1). In this change script using another message handler send the currentValue to the flex instance. So flex instances are aware of the current index
That is exactly what I did
I wasn’t able to make the instances parameters to update without the script running all over again, so I thought that the solution would be a adding a message handler from flex repeater to the instances.
Hopefully this is the best solution to your case
Why don't you just modify the CSS class rule for selected buttons - perhaps even only those with a specific class? Then you don't have to maintain any registry or book-keeping.
.psc-MyFocusClass:focus {
bottom-border: 3px;
}
Edit #1: Actually you may just be able to do this within the Named Styles, without needing to include the stylesheet.css resource by specifying the state for the class.
Edit #2: Unless you are clicking somewhere else after having clicked the Button... at which point you will need to "register" the Button last clicked.
I think that’s the whole point.
But I feel like messages are a bit over complicated for this case.
I’d suggest a different method but I’d rather make sure it works first, I’ll try it tomorrow and report back.