[Ur] More questions: sql_injectable, reactivity and interaction with CSS

Artyom Shalkhakov artyom.shalkhakov at gmail.com
Tue Jan 12 23:17:04 EST 2010


Oops. Thanks!

I'm feeling kinda stupid. :)

Cheers,
Artyom Shalkhakov.

2010/1/12, Adam Chlipala <adamc at impredicative.com>:
> Artyom Shalkhakov wrote:
>> Here's what I do:
>>
>>> fun editable () =
>>>    m<- source False; (* mode: editing or viewing *)
>>>    t<- source "click to edit";
>>>    let
>>>      fun act () =
>>>        m'<- signal m;
>>>        return (if m' then
>>>           <xml><ctextbox source={t}/><button onclick={set m
>>> False}/></xml>
>>>        else<xml><dyn signal={t'<- signal t; return (cdata t')}/></xml>
>>>    in
>>>      return<xml><body>
>>>        <div onclick={m'<- get m; if not m' then set m True else return
>>> ()}>
>>>          <dyn signal={act ()}/>
>>>        </div>
>>>      </body></xml>
>>>    end
>>>
>> I think it should work but actually clicking on the button doesn't
>> revert the mode from editing to viewing. Is there something I do
>> wrong?
>>
>
> Yes, and in fact it's just a simple misunderstanding, based on semantics
> inherited from HTML/JavaScript.  The <button> you create is inside the
> <div> with an 'onclick' attribute.  Thus, when you click on the button,
> _both_ 'onclick' handlers run.  The <div>'s handler cancels the effect
> of the <button>'s handler!  (You can add some [alert] calls to forcibly
> pause the process at different points; this lets you see the text appear
> and then disappear again.)
>
> _______________________________________________
> Ur mailing list
> Ur at impredicative.com
> http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
>



More information about the Ur mailing list