Two Way Binding an Input with RactiveJs -
i'm starting out ractivejs , having few troubles observing input tag, rendered value.
i'm observing input field below.
{{#invoices:i}} <input class="text-center" type="date"" value="{{***date_modified***}}"> {{/invoices}}
using below
ractive.observe({ '*.*.date_modified': function(newvalue, ***oldvalue***, keypath) { // function }; });
the challenge first time "date_modified" changed "oldvalue" undefined. second time "date_modified" changed "oldvalue" correctly returns old value.
the "date_modified" rendered value (e.g., 22/11/2014), suspect might issue of examples leave input blank when template
any thoughts?
thanks
by default, observers 'initialise' undefined oldvalue
- idea it's easier write single function current state of app, regardless of how state came be, rather initial setup logic plus separate change handler of kind.
but can disable first call passing init: false
option, so:
ractive.observe('foo', handler, { init: false });
however there's bit more in case. turns out you've uncovered bug - pattern observers can't have *
first key. you'd need use invoices.*.date_modified
instead of *.*.date_modified
. issue has been raised on github - thanks!
Comments
Post a Comment