David Kurkovskiy
David Kurkovskiy

Reputation: 25

Using JQuery with Dart for Input autosuggest

I've been having trouble using JQuery with Dart to allow an input field to suggest text from a pre-selected list.

I am getting a NoSuchMethod error with the following code:

js.scoped(() {
    js.context.jQuery("#input").autocomplete({source: ['hi', 'hello', 'bye']});
});

(Just a note, I tried to avoid JQuery for this, but the only Dart auto suggest library I found -- autocomplete-ui -- threw me errors every time I tried to put the component in my template.)

Thanks in advance!

Upvotes: 2

Views: 1248

Answers (1)

Alexandre Ardhuin
Alexandre Ardhuin

Reputation: 76353

Try :

js.context.jQuery("#input")
  .autocomplete(js.map({'source': ['hi', 'hello', 'bye']}));

Basically you have to convert the Dart map with js.map.

You can also get rid of js.scoped that is no longer needed.

Upvotes: 1

Related Questions