[Ur] An initial wild guess attempting to wrap a Bootstrap DatePicker for Ur/Web

Timothy Beyer beyert at fastmail.net
Sun Aug 2 21:54:37 EDT 2015


At Sun, 2 Aug 2015 17:53:54 -0700,
Ziv Scully wrote:
> 
> The Ur/Web manual section on IDs (http://www.impredicative.com/ur/manual.pdf, section 8.6.2)
> specifies that [id] is an abstract type, with the only way to generate them being [fresh :
> transaction id]. It also makes clear that there's no way to force the ID to be something in
> particular.
> 
> The pattern that Logitext uses is to generate a unique ID and both set a node's ID with it
> and pass it to a JavaScript function via the FFI. This seems like exactly the way to do what
> you need. For your case, it would look something like this:
> 
> datepicker : transaction xml =
>     nid <- fresh;
>     return <xml>
>       <div id={nid}/>
>       <active code={annotateDatepicker nid; return <xml/>}/>
>     </xml>
> 
> where [annotateDatepicker : id -> transaction unit] is an JavaScript FFI function that takes
> an ID and calls the function from the JavaScript library using that ID. In this case, that
> would be
> 
> function annotateDatepicker(nid) {
>     $('#' + nid + ' div').datepicker({})
> }
> 
> or something similar (not an expert on this library). It's possible you could put the
> [annotateDatepicker] call outside the XML right after the [nid <- fresh;], but I don't know
> if it would work.

Sorry, I was referring to Javascript itself, not Ur/Web, I misread his
question.

Tim



More information about the Ur mailing list