elm mdl - Why does elm-mdl dialog close automatically? -


the documentation elm-mdl's dialog module states:

the elm-mdl library support 1 dialog pr. application. installing more 1 dialog result in random 1 showing.

i'm trying find work-around this, , have working. i've created own dialog module contains various view functions , union type, view, determines view function call in mdl dialog. when open mdl dialog in main module's view code, initialize custom dialog module view value, , bam, displays correct view.

however, first time open dialog, closes immediately. when log main module's calls msg, see dialog's closeon button has been clicked, though haven't clicked button.

here's code

main.elm

module main exposing (..)  import html exposing (..) import material import material.scheme scheme import material.color color import material.options options import material.button button import material.dialog mdialog import dialog.dialog dialog   type alias model =     { dialog : maybe dialog.model     , mdl : material.model     }   init : ( model, cmd msg ) init =     ( { dialog = nothing       , mdl = material.model       }     , cmd.none     )   type msg     = opendialog dialog.view     | dialogmsg dialog.msg     | mdl (material.msg msg)   update : msg -> model -> ( model, cmd msg ) update msg model =     let         check =             debug.log "msg" msg     in         case msg of             opendialog view ->                 let                     ( dialogmodel, dialogeffects ) =                         dialog.init view                      dialogmsg =                         cmd.map dialogmsg dialogeffects                 in                     { model | dialog = dialogmodel } ! [ dialogmsg ]              dialogmsg msg_ ->                 case model.dialog of                     nothing ->                         model ! []                      dialogmodel ->                         let                             ( newmodel, dialogeffects ) =                                 dialog.update msg_ dialogmodel                         in                             { model | dialog = newmodel } ! [ cmd.map dialogmsg dialogeffects ]              mdl msg_ ->                 material.update mdl msg_ model   view : model -> html msg view model =     scheme.topwithscheme color.teal color.red (dialogtestview model)   dialogtestview : model -> html msg dialogtestview model =     options.div []         [ button.render mdl             [ 0 ]             model.mdl             [ mdialog.openon "click"             , options.onclick (opendialog dialog.d0)             ]             [ text "dialog 0" ]         , button.render mdl             [ 1 ]             model.mdl             [ mdialog.openon "click"             , options.onclick (opendialog dialog.d1)             ]             [ text "dialog 1" ]         , button.render mdl             [ 2 ]             model.mdl             [ mdialog.openon "click"             , options.onclick (opendialog dialog.d2)             ]             [ text "dialog 2" ]         , dialog model         ]   dialog : model -> html msg dialog model =     case model.dialog of         nothing ->             mdialog.view                 []                 [ mdialog.title [] [ text "hello!" ]                 , mdialog.content [] []                 , mdialog.actions []                     [ button.render mdl                         [ 3 ]                         model.mdl                         [ mdialog.closeon "click" ]                         [ text "close" ]                     ]                 ]          dialogmodel ->             html.map dialogmsg (dialog.view dialogmodel)   main =     html.program { init = init, view = view, update = update, subscriptions = (\m -> sub.none) } 

dialog/dialog.elm

module dialog.dialog exposing (..)  import html exposing (..) import material import material.dialog dialog import material.button button   type alias model =     { view : view     , mdl : material.model     }   init : view -> ( model, cmd msg ) init view =     ( model view, cmd.none )   model : view -> model model view =     { view = view     , mdl = material.model     }   type msg     = mdl (material.msg msg)   update : msg -> model -> ( model, cmd msg ) update msg model =     case msg of         mdl msg_ ->             material.update mdl msg_ model   type view     = d0     | d1     | d2   view : model -> html msg view model =     let         ( title, content, actions ) =             case model.view of                 d0 ->                     d0 model                  d1 ->                     d1 model                  d2 ->                     d2 model     in         dialog.view []             [ dialog.title [] title             , dialog.content [] content             , dialog.actions [] actions             ]   d0 : model -> ( list (html msg), list (html msg), list (html msg) ) d0 model =     ( [ text "hello!" ]     , [ text "d0" ]     , [ button.render mdl             [ 3 ]             model.mdl             [ dialog.closeon "click" ]             [ text "close" ]       ]     )   d1 : model -> ( list (html msg), list (html msg), list (html msg) ) d1 model =     ( [ text "hello!" ]     , [ text "d1" ]     , [ button.render mdl             [ 3 ]             model.mdl             [ dialog.closeon "click" ]             [ text "close" ]       ]     )   d2 : model -> ( list (html msg), list (html msg), list (html msg) ) d2 model =     ( [ text "hello!" ]     , [ text "d2" ]     , [ button.render mdl             [ 3 ]             model.mdl             [ dialog.closeon "click" ]             [ text "close" ]       ]     ) 


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -