Skip to content

“placeholder” attribute using knockout – JSON

I would like to use placeholder attribute using data-bind but I have a error message([object object]) . Please let me know how can I use it.

html:

input id="comments" class="form-control" 
data-bind="attr: { placeholder: { locale: 'placeholder.comments', auth: false } }"

json:

"placeholder": {
    "comments": "Tell us..."
}

Answer

The placeholder attribute should be a string (ko.observable), not an object.

<input data-bind="attr:{placeholder:hintText}" />

Simple example: http://jsfiddle.net/xtdL7om1/