Of course, thanks!

On Friday, June 23, 2017 at 1:37:08 PM UTC+2, Peter Damoc wrote:
>
> Hi Casper, 
>
> Just force an empty value when the age is 0 
> Like this:
> https://ellie-app.com/3yrgPqxp52ha1/0
>
>
> On Fri, Jun 23, 2017 at 12:08 PM, Casper Bollen <[email protected] 
> <javascript:>> wrote:
>
>> I wrote a small program as a newbie project in Elm: 
>> https://ellie-app.com/3ynWqjPcP87a1/0.
>>
>> In this program I calculate the correct input field according to the 
>> value in the model:
>>
>> view : Model -> Html Msg
>> view model =
>>     let
>>         toInput attrs =
>>             input attrs []
>>
>>         ageInput =
>>             let
>>                 attrs =
>>                     if model.age == 0 then
>>                         [ name "age", type_ "number", placeholder "Leeftijd 
>> in jaren" ]
>>                     else
>>                         [ name "age", type_ "number", value (toString 
>> model.age) ]
>>
>>                 _ =
>>                     Debug.log "Attrs" attrs
>>             in
>>                 attrs
>>                     |> List.append [ onInput Update ]
>>                     |> toInput
>>     in
>>         div [ style [ ( "margin", "100px" ) ] ]
>>             [ div [] [ text "Voer een leeftijd in" ]
>>             , ageInput
>>             , button [ onClick Calculate ] [ text "Bereken" ]
>>             , div [] [ text ("Gewicht: " ++ toString (model.weight) ++ " 
>> kg") ]
>>             ]
>>
>>
>> However, if you count up and then down to zero, the input field is 
>> rendered correctly showing the placeholder when age = 0. But when you count 
>> down to negative values, the negative values are shown, although the 
>> model.age value = 0.
>>
>> Furthermore, the Debug.log "Attrs" is never shown in the debug view.
>>
>> What am I doing wrong?
>>
>> -- 
>> 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