<div dir="ltr">This is a very cool trick! I happened to need this: I'm making a filtering page with a ton of checkboxes, and every time I check any one of them, I want to reload stuff from the server. My first solution was to add my "reloadStuff" function in every onchange handler of every checkbox. I've now replaced that with the trick mentioned above: one dyn tag which depends on the signals of every checkbox source, and it renders a script tag when something changes. Much cleaner! Have to be a little bit careful that I don't start abusing this though.<div><br></div><div>Side note: the <script> tag in basis can only be placed in the <head> part of an html document, so if you want to apply this you'll need to use the JS ffi to make a new "bodyscript" tag, as mentioned in the manual in chapter 11.3)</div></div><br><div class="gmail_quote"><div dir="ltr">Op wo 4 jul. 2018 om 22:16 schreef Adam Chlipala <<a href="mailto:adamc@csail.mit.edu">adamc@csail.mit.edu</a>>:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <div class="m_7503737947896293531moz-cite-prefix">Let me try to disentangle the potential
      parts of your question.<br>
      <br>
      I hope you are not asking about literally writing code in
      JavaScript.  I will proceed as though you are actually asking
      about <i>client-side code</i>, but let me know if I
      misunderstood.  (It is a rather nice feature of Ur/Web that
      writing Ur/Web programs need not involve JavaScript at all,
      anymore than we talk about "transistors" when reading JavaScript
      code!)<br>
      <br>
      So, then, I conclude that your question is how to add a listener
      on a [source], to run arbitrary client-side code whenever the
      source changes.  You seem to be on a good track there, with the
      mention of a dummy node.  I would create a <dyn> node that
      generates only a <script> node, whose 'code' handler will
      then be run whenever the source changes, such that this
      <dyn> node contributes no content to the page.<br>
      <br>
      On 07/04/2018 04:10 PM, Fabrice Leal wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr">is it possible to trigger javascript code when
        calling 'set s ...' ? 
        <div><br>
        </div>
        <div>as i understand the main usage seems to be regenerating
          html node trees; i think i could get away with generating some
          dummy html node with the javascript call in onload event, but
          I'm asking just to make sure I'm not missing anything.
          <div><br>
          </div>
          <div>my goal is, for instance, to update some state on the
            client side and trigger a canvas redraw,</div>
          <div>since i seem to be unable to call '... <- signal s;'
            inside a 'transaction page'</div>
        </div>
      </div>
    </blockquote>
    <br>
  </div>

_______________________________________________<br>
Ur mailing list<br>
<a href="mailto:Ur@impredicative.com" target="_blank">Ur@impredicative.com</a><br>
<a href="http://www.impredicative.com/cgi-bin/mailman/listinfo/ur" rel="noreferrer" target="_blank">http://www.impredicative.com/cgi-bin/mailman/listinfo/ur</a><br>
</blockquote></div>