简体   繁体   English

结合使用JQuery和Dart进行输入自动建议

[英]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. 我一直在使用带有Dart的JQuery来允许输入字段建议预选列表中的文本时遇到麻烦。

I am getting a NoSuchMethod error with the following code: 我收到以下代码的NoSuchMethod错误:

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.) (仅需注意,我尝试避免使用JQuery,但是每次我尝试将组件放入模板时,我发现的唯一Dart自动建议库-autocomplete-ui-抛出了错误。)

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 . 基本上,您必须使用js.map转换Dart地图。

You can also get rid of js.scoped that is no longer needed. 您还可以摆脱不再需要的js.scoped

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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