实现。访问自动完成元素属性
我想答案应该很容易,但是我要生气地试图找到答案。
可以说,我有这样的物质化的自动完成元素。
$('#element_id).autocomplete({
limit:5,
data:{"a":null,"b":null,"c":null},
onAutocomplete:function(){whatEverYouWannaDoAfterCompletion()}
});
但是,获得所选值没有问题,我的问题是... 是否可以使用ActiveIndex自动完成项目属性获得所选的索引,或者我应该“导航”通过渲染的组件来找到所选的术语?
谢谢。
I guess answer should be easy, but I´m going mad trying to find an answer.
Let´s say that I have a Materialize autocomplete element defined like this.
$('#element_id).autocomplete({
limit:5,
data:{"a":null,"b":null,"c":null},
onAutocomplete:function(){whatEverYouWannaDoAfterCompletion()}
});
However, getting the selected value has no problem, my question is...
Is it possible to get selected index with activeIndex autocomplete item property or should I "navigate" throught rendered component to find the selected ocurrence?.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尽管最终目标对我来说尚不清楚,但我将尝试至少阐明属性 ActiveIndex 等等。
在这里,我准备了一个时间驱动的函数,以检查属性,而无需依赖元素焦点。关键步骤是将元素实例在物质空间(而不是jQuery!)中获取。
至于属性的理解,我认为我们应该在使用之前仔细测试它们。在我的测试中,即使选择完全匹配选项值,我也看到了唯一的
activeIndex = -1
值。预期的行为与我不同。Although the final goal is not clear for me, I'll try to clarify at least how access the property activeIndex and some more.
Here I prepared a time-driven function to check properties with no dependency on the element focus. The key step is to get the element instance in Materialize space (not jQuery!).
As for the properties sense understanding, I think we should test them carefully before using. In my tests I have seen the only
activeIndex=-1
value even if the selection match the option value entirely. The expected behavior is different to my mind.