Skip to content
Advertisement

“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..."
}

Advertisement

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/

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement