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

Autocomplete widget

enter red green or blue and see a hint list below the input box

Running example

(in the light red box):


when submit is pressed, the box value is returned

Source code:

{-# OPTIONS -XCPP #-} 
module AutoComplete ( autocomplete1) where
import Data.List

-- #define ALONE
#ifdef ALONE
import MFlow.Wai.Blaze.Html.All
main= runNavigation "" $ transientNav autocomplete1
import MFlow.Wai.Blaze.Html.All hiding(page)
import Menu

autocomplete1= do
   r <- page $   pageFlow "auto"
             $   p <<  "Autocomplete "
             ++> p <<  "when submit is pressed, the box value  is returned"
             ++> wautocomplete Nothing filter1 <! hint "red, green or blue"
             <** submitButton "submit"
   page  $ p << (show r ++ " selected")  ++> wlink () (p <<  " menu")

   filter1 s = return $ filter (isPrefixOf s)
                        ["red","red rose","green","green grass","blue","blues"]

hint s= [("placeholder",s)]

comments powered by Disqus