Cool!

How can I implement a single selection ? :-)

On Saturday, September 17, 2016 at 1:10:43 PM UTC+3, Peter Damoc wrote:
>
> Yes, with a map:
>
> case msg of 
>     DeploySelected deployment -> 
>         let 
>             toggleSelect (d, s) = 
>                 if d == deployment then 
>                     not s
>                 else 
>                     s 
>         in    
>             { model | deployments = List.map toggleSelect model.deployments 
> } 
>
>
>
> The above approach assumes multiple selections and a toggle state where if 
> you click again on something you deselect it. 
>
>
>
>
> On Sat, Sep 17, 2016 at 12:51 PM, Roni Hacohen <[email protected] 
> <javascript:>> wrote:
>
>> Peter, thank you for your answer!
>>
>> I was trying to do it that way, the problem is I'm not sure how to set 
>> the selected deployment as True when selected.
>> How can I find an element in a List and change it? with a map maybe?
>>
>> On Saturday, September 17, 2016 at 12:43:38 PM UTC+3, Peter Damoc wrote:
>>>
>>> viewDeploy: (String, Bool) -> Html Msg
>>> viewDeploy (deployment, isSelected) =
>>>     li
>>>       [ classList [("selected", isSelected)],  onClick (DeploySelected 
>>> deployment) ] 
>>>       [ text deployment ]
>>>
>>> viewDeployments : List (String, Bool) -> Html Msg
>>> viewDeployments deployments =
>>>     ul [] ( List.map viewDeploy deployments )
>>>
>>>
>>> This is one way to do it.
>>>
>>>
>>> On Sat, Sep 17, 2016 at 12:14 PM, Roni Hacohen <[email protected]> 
>>> wrote:
>>>
>>>> Hello,
>>>>
>>>> I'm wondering what is the best solution for my problem,
>>>>
>>>> I have a List of deployments, once the user choses a deployment he will 
>>>> get more details about it,
>>>> the view looks like this:
>>>>
>>>> viewDeploy: String -> Html Msg
>>>> viewDeploy deployment =
>>>>     li
>>>>       [onClick (DeploySelected deployment)] [ text deployment ]
>>>>
>>>> viewDeployments : List String -> Html Msg
>>>> viewDeployments deployments =
>>>>     ul [] ( List.map viewDeploy deployments )
>>>>
>>>>
>>>> Now, I want to add a classList to the li that will change its color,
>>>> what is the best way to mark that deployment as selected?
>>>>
>>>> Thanks!
>>>>
>>>> -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "Elm Discuss" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to [email protected].
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>
>>>
>>> -- 
>>> There is NO FATE, we are the creators.
>>> blog: http://damoc.ro/
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Elm Discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> There is NO FATE, we are the creators.
> blog: http://damoc.ro/
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to