work on syncing model to DOM
@@ -173,10 +173,27 @@ impl<Ms> Listener<Ms> {
{
// This and detach taken from Draco.
let mut handler = self.handler.take().expect("Can't find old handler");
-
+ let trigger = self.trigger.clone();
let closure =
Closure::wrap(
- Box::new(move |event: web_sys::Event| mailbox.send(handler(event)))
+ Box::new(move |event: web_sys::Event| {
+ let msg = handler(event.clone());
+ if trigger == Ev::Input{
+ let target = event.target().unwrap();
+ let input_el = crate::to_input(&target);
+
+ let value = input_el.value();
+ if value == ""{
+ let default_value = input_el.default_value();
+ input_el.set_value(&default_value);
+ log!("setting default_value", default_value);
+ }else{
+ input_el.set_value(&value);
+ log!("setting value", value);
+ }
+ }
+ mailbox.send(msg);
+ })
as Box<FnMut(web_sys::Event) + 'static>,
);
