简体   繁体   中英

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM