I have an input text box on my page and I need to have the width of this input box adjusted to his content. So for example: if there are only 2 characters inside of it then my input box should be smaller than if I have 10 characters in it.
I am able to do it with jQuery but this time I really wonder myself if this can be done with knockout?
Here is a jsFiddle as a starting point: http://jsfiddle.net/LkqTU/13554/
As you can see in this jsFiddle, the input text box for the content 'abc' is too much bigger... And when you click the button, then the input text box is too much smaller.
So what i need is a 'mechanism' where the box is automatically adjusted based on his content.
<input type="text" data-bind="value: myField">
<input type="button" value="Click me" data-bind="click: buttonClicked">
var ViewModel = function() {
this.myField = ko.observable('abc');
this.buttonClicked = function() {
this.myField('azertyuiolkjhgfdsseryuujnbvcxsssx');
}
};
ko.applyBindings(new ViewModel());
Thanks.