Typeahead.js: How to enable/disable input box?

Created on 17 Feb 2015  路  1Comment  路  Source: twitter/typeahead.js

I'd like to control enable/disable input box.
How to do?

Now, i write like this.

$('.typeahead).typeahead(.....);
$('.typeahead).on('typeahead:selected', function ...)

...

$(selector)
.removeAttr('disabled')
.prev().remove()
.removeClass('.typeahead')
.addClass('.typeahead');

...

But, I don't know .prev().remove() is sufficient or not.
Could you please support this api?

Most helpful comment

I'm curious why this was closed and if there is a proper way to dynamically disable/enable the input field to which typeahead.js is applied. I'm using Vue.js to control when a field is disabled.

<input type="text" v-bind:value="person.name" v-bind:disabled="disabled">

What seems to be happening is that the input associated with tt-input seems to update properly, but the tt-hint input field does not. It seems to stay in the initial state of tt-input when typeahead was applied.

Since tt-input is transparent, the ghosting doesn't update properly. eg when disabled turns to false, tt-input is enabled, but tt-hint isn't, so the input field stays greyed out.

>All comments

I'm curious why this was closed and if there is a proper way to dynamically disable/enable the input field to which typeahead.js is applied. I'm using Vue.js to control when a field is disabled.

<input type="text" v-bind:value="person.name" v-bind:disabled="disabled">

What seems to be happening is that the input associated with tt-input seems to update properly, but the tt-hint input field does not. It seems to stay in the initial state of tt-input when typeahead was applied.

Since tt-input is transparent, the ghosting doesn't update properly. eg when disabled turns to false, tt-input is enabled, but tt-hint isn't, so the input field stays greyed out.

Was this page helpful?
0 / 5 - 0 ratings