[Ur] New attempt to wrap a simple JS datepicker library (Pikaday) to use with Ur/Web
Ziv Scully
ziv at mit.edu
Fri Aug 7 01:51:12 EDT 2015
I noticed the unit method was called in the onload in the body. In
Logitext, analogous methods are always called in an <active> following the
(in its case) <div id={nid}>. Perhaps the onload can't yet do anything to
the element you set the nid on because it doesn't yet exist.
I think I put this pattern in a previous email, but here it is again. I
think you'll want something like:
<textbox{#Field} id={nid}/>
<active code={init nid; return <xml/>}/>
More generally, we have the question of how best to interface with
mutation-heavy JS libraries. You can make this seem a bit more declarative
by writing a wrapper function (see [activate] in Logitext), but maybe there
are other approaches that are nicer in some ways (e.g. could the FFI be
just a value of type [transaction xbody]?).
On Thursday, August 6, 2015, Stefan Scott Alexander <
stefanscottalexx at gmail.com> wrote:
> Thanks Ziv.
>
> I added the following two lines to pikadayPage.urp:
>
> jsFunc PikadayControl.init=init
> benignEffectful PikadayControl.init
>
> The revised code is on the GitHub repo:
>
> https://github.com/StefanScott/urweb-pikaday
>
> Now the code compiles and runs - and if I type "foo" in the textbox and
> hit Submit, then the web app correctly goes to another page and displays
> "foo".
>
> However, when I click in the textbox, it does *not* display a datepicker,
> so I must still be doing something wrong.
>
> I think the code might be *close* to being correct, but obviously I
> haven't connected all the pieces together correctly.
>
> I'm purposely using this minimal example in the hopes that it might make
> it easier to pinpoint where the error is.
>
> ###
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.impredicative.com/pipermail/ur/attachments/20150806/a1eb8b52/attachment.html>
More information about the Ur
mailing list