[Opa] is there a way to "flush" Dom events?

Frederic Ye frederic.ye at mlstate.com
Mon Jan 23 02:00:52 UTC 2012

Depending on the browser, the dom transformation seems to be handled different ways (before, after ...)

Here is a code you can try : 

import stdlib.themes.bootstrap

@server @async
// just a busy loop to cause a delay for demonstration purposes
busyness(remaining:int) =
  do Scheduler.wait(2000)

process_form() =
  foo = Dom.get_value(#foo_input)
  do Dom.hide(#formdiv)
  do Dom.transform([#success <- "you said { foo }"])

freeze_button_and_go(_) =
  do Dom.add_class(#submit, "disabled")
  do Dom.set_enabled(#submit, {false})
  do Dom.transform([#submit_going <- "going..."])
  do busyness(50)

show_form() =
  <div id=#formdiv onready={_ -> Dom.give_focus(#foo_input)}>
   <form method="get" onsubmit={freeze_button_and_go} action="javascript:void(0)">
    <div id=#foo_div class="clearfix">
     <label for="foo_input">foo:</label>
     <div class="input">
      <input class="xlarge"
             type="text" name="foo_input" size="25"/>
    <div class="actions">
     <button class="btn primary" id=#submit>go</button>
     <span class="help-inline" id=#submit_going></span>
  <div id=#success/>

server =
  Server.one_page_server("test", show_form)

I'll let you study it. If you have any questions, do not hesitate to ask ;)

On 23 janv. 2012, at 02:17, Owen Gunden wrote:

> Hello! I've attached some test code that presents a tiny form with a
> toy response.
> I would like the "go" button to grey out right away after it's
> clicked. However, my client doesn't render the Dom changes until after
> the entire onSubmit handler returns (including the call to busyness()
> which takes a while).
> Is there some buffering up of Dom events that are to be sent to the
> client, and if so, is there a way to flush them? If not, any
> suggestions on another way to get immediate feedback to the user when
> they've clicked the button?
> Thanks!
> <test.opa>_______________________________________________
> Opa mailing list
> Opa at lists.owasp.org
> https://lists.owasp.org/mailman/listinfo/opa

More information about the Opa mailing list