I am brand new to knockout.js - I have taken over an existing app written in it, the previous maintainers having left - and I want to start by writing tests that exercise the whole thing from outside it. Most pages are quite straightforward, but I've encountered this:
<textarea maxlength="4000"
data-bind="valueWithPlaceholder: answerValue,
placeholder: exampleText,
maxLengthCountdown: answerValue"></textarea>
this is inside a with, inside loops inside another with etc - and I have no real interest in figuring out the whole schema at this point - I just want to set it to something with javascript..
- I've tried element.value = "blah" - it sets the value visibly, but doesn't seem to affect the binding in any way - going "next" still says I have to enter something
- I've tried doing element.focus(), a whole bunch of element.dispatchEvent( new KeyboardEvent(...) with keydown, keypress and key up, and then element.blur() and nothing at all happens
any ideas how I set it? I want some way that is not tied to understanding the schema - because I have a bunch of these to set, and want to build some function along the lines of "set_text_area( element, value )". I'm really looking for something like:
element.value = "blah"
knockout.force_update_binding( element ); // I'm imagining this exists
Note: What I'm asking is how to set a value programmatically from an element and without knowing anything about the underlying model. Obviously if I know the model, then I just set it - but I'm just clicking on an element in my test harness and wanting to type a value in - and my test harness can't go and "understand" stuff.