如何处理我从自动完成列表中选择的值?

时间:2016-09-25 12:51:36

标签: autocomplete codemirror

我正在使用codemirror编辑器...当我进行自动完成时我需要我从下拉列表中选择项目来处理(获取)所选的值...可以帮助我吗?

1 个答案:

答案 0 :(得分:2)

您是否尝试对所选项目执行某些操作?如果是这样,您应该收听pick对象上的completion事件。你可以这样做:

...
var completion = {list: someHintList, from: somePos, to: somePos};
CodeMirror.on(completion, "pick", function(selectedItem) {
  // Do something with the selectedItem.
  // This function would be called after user pick a item from the list.
}
return completion;

有关详细信息,请查看document about hint addon