F#
HTML
Result
Hosted on
Try WebSharper
<
>
namespace Repro open WebSharper open WebSharper.UI.Next open WebSharper.UI.Next.Html open WebSharper.UI.Next.Client [<JavaScript>] module Lensing = // Input loses focus: // ----------------- // let aliases = // ListModel.Create id [ "Bill"; "Joe" ] // let lensIntoAlias aliasKey = // aliases.LensInto id (fun a n -> n) aliasKey // let Main = // div [ // aliases // .View // .DocSeqCached (fun (aliasKey: string) -> // div [ // Doc.Input [] (lensIntoAlias aliasKey) // ] // ) // hr [] // aliases // .View // .DocSeqCached (fun (aliasKey: string) -> // div [ Doc.TextView (lensIntoAlias aliasKey).View ] // ) // ] // |> Doc.RunById "main" // Workaround 1: // ------------ type Alias = { Key: int; Value: string } let aliases = ListModel.Create (fun a -> a.Key) [ { Key = 1; Value = "Bill" }; { Key = 2; Value = "Joe" } ] let lensIntoAlias aliasKey = aliases.LensInto (fun a -> a.Value) (fun a n -> { a with Value = n }) aliasKey let Main = div [ aliases ] |> Doc.RunById "main"
<html> <head> <title></title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" /> </head> <body> <div id="main"></div> <!--[BODY]--> </body> </html>