Giving the following setup:
<textarea id="textarea-chat" type="text" data-bind="value: chatMessage" />
I'd like to open the developer console and manually set the value of chatMessage
document.getElementById('textarea-chat').value = 'somevalue';
Will change the content of the of the DOM element, but not the observer value.
Accessing chatMessage()
results in undefined
Suggestions are welcome
Taking the ideas from here and here, you need to access the value of chatMessage through the ViewModel, which is available in the console when you use the
ko.dataFor()
method. So, the steps would be:var vm = ko.dataFor(document.body)
vm.chatMessage('somevalue')