I have an input field that holds currency value. I am trying to display formatted currency amount when the input field does not have focus. The input type is set to number. While this works fine on Chrome, IE and Edge; on firefox, the input textbox loses focus immediately after getting it. Here is the simplified jsfiddle
https://jsfiddle.net/nkkfmLmc/2/
Any pointers or workarounds would be appreciated.
HTML:
<p>
Name:
<b data-bind="visible: !editing(), text: '$'+amount(), click: edit"> </b>
<input type="number" min="0" max="100" step="1" data-bind="visible: editing, value: amount, hasFocus: editing" />
</p>
<p><em>Click the amount to edit it; click elsewhere to apply changes.</em></p>
JS:
function PersonViewModel(amount) {
// Data
this.amount = ko.observable(amount);
this.editing = ko.observable(false);
// Behaviors
this.edit = function() { this.editing(true) }
}
ko.applyBindings(new PersonViewModel(51.22));