comparison doc/manual.tex @ 1785:ffd7ed3bc0b7

Basis.giveFocus
author Adam Chlipala <adam@chlipala.net>
date Sat, 21 Jul 2012 11:59:41 -0400
parents 5bc4fbf9c0fe
children d794149b3713
comparison
equal deleted inserted replaced
1784:e6bc6bbd7a32 1785:ffd7ed3bc0b7
2091 $$\begin{array}{l} 2091 $$\begin{array}{l}
2092 \mt{type} \; \mt{id} \\ 2092 \mt{type} \; \mt{id} \\
2093 \mt{val} \; \mt{fresh} : \mt{transaction} \; \mt{id} 2093 \mt{val} \; \mt{fresh} : \mt{transaction} \; \mt{id}
2094 \end{array}$$ 2094 \end{array}$$
2095 2095
2096 The \cd{fresh} function is allowed on both server and client, but there is no other way to create IDs, which includes lack of a way to force an ID to match a particular string. The only semantic importance of IDs within Ur/Web is in uses of the HTML \cd{<label>} tag. IDs play a much more central role in mainstream JavaScript programming, but Ur/Web uses a very different model to enable changes to particular nodes of a page tree, as the next manual subsection explains. IDs may still be useful in interfacing with JavaScript code (for instance, through Ur/Web's FFI). 2096 The \cd{fresh} function is allowed on both server and client, but there is no other way to create IDs, which includes lack of a way to force an ID to match a particular string. The main semantic importance of IDs within Ur/Web is in uses of the HTML \cd{<label>} tag. IDs play a much more central role in mainstream JavaScript programming, but Ur/Web uses a very different model to enable changes to particular nodes of a page tree, as the next manual subsection explains. IDs may still be useful in interfacing with JavaScript code (for instance, through Ur/Web's FFI).
2097
2098 One further use of IDs is as handles for requesting that \emph{focus} be given to specific tags.
2099
2100 $$\begin{array}{l}
2101 \mt{val} \; \mt{giveFocus} : \mt{id} \to \mt{transaction} \; \mt{unit}
2102 \end{array}$$
2097 2103
2098 \subsubsection{\label{signals}Functional-Reactive Page Generation} 2104 \subsubsection{\label{signals}Functional-Reactive Page Generation}
2099 2105
2100 Most approaches to ``AJAX''-style coding involve imperative manipulation of the DOM tree representing an HTML document's structure. Ur/Web follows the \emph{functional-reactive} approach instead. Programs may allocate mutable \emph{sources} of arbitrary types, and an HTML page is effectively a pure function over the latest values of the sources. The page is not mutated directly, but rather it changes automatically as the sources are mutated. 2106 Most approaches to ``AJAX''-style coding involve imperative manipulation of the DOM tree representing an HTML document's structure. Ur/Web follows the \emph{functional-reactive} approach instead. Programs may allocate mutable \emph{sources} of arbitrary types, and an HTML page is effectively a pure function over the latest values of the sources. The page is not mutated directly, but rather it changes automatically as the sources are mutated.
2101 2107