MFlow  Create and maintain dynamic Web applications as easy and fast as console applications
Thou shall not write request handlers
 This release: 11/06/2014. (@agocorona) <>< . issues & bugs .  Mflow Source code,     source code of this site

Edition of a list of widgets

Example of a widget that edit, update and delete a list of user-defined widgets. In this case the widget is a text box with a delete checkbox attached 

Running example

(in the light red box):

Source code:

{-# LANGUAGE OverloadedStrings, CPP #-}
module ListEdit ( wlistEd) where

import Text.Blaze.Html5 as El
import Text.Blaze.Html5.Attributes as At hiding (step)
import Data.String
-- #define ALONE
#ifdef ALONE
import MFlow.Wai.Blaze.Html.All
main= runNavigation "" $ transientNav wlistEd
import MFlow.Wai.Blaze.Html.All hiding(page)
import Menu

wlistEd= do
   r <-  page   $ pageFlow "listed" $
              ++> br
              ++> (wEditList El.div getString1   ["hi", "how are you"] "wEditListAdd")
              <++ br
              <** submitButton "send"

   page  $   p << (show r ++ " returned")
       ++> wlink () (p " back to menu")

   addLink = a !  "wEditListAdd"
               ! href  "#"
               $ b "add"
   delBox  =  input ! type_    "checkbox"
                    ! checked  ""
                    ! onclick  "this.parentNode.parentNode.removeChild(this.parentNode)"
   getString1 mx= El.div  <<< delBox ++> getString  mx <++ br

-- to run it alone, change page by ask and uncomment this:
--main= runNavigation "" $ transientNav wListEd

comments powered by Disqus