If I have the following code, where knockout binds the textarea to Text the global object, instead of Text on the viewModel. Can knockout be told to use any local property of the viewModel before trying global ones?
I know I can do viewModel.Text, but I prefer not to. Besides, I might want to use the same code for myotherviewModel without changing the markup.
I’d prefer to do window.Text if I want to call the global function.
<textarea data-bind="value:Text"></textarea>
JS:
var viewModel={
Text : 'my text'
};
ko.applyBindings(viewModel)
Can you clarify your scenario? KO does a
withwhen evaluating bindings, so the viewModel variables would be found before a global variable like in this sample: http://jsfiddle.net/rniemeyer/Um6Y6/ – RP Niemeyer Sep 15 at 12:49