CodeMirror自定义showHint()调用不会'不起作用
CodeMirror custom showHint() call doesn't work
正在尝试为拼写检查模块实现自定义showHint
调用。我已经遵循了文档,但调用editor.showHint
似乎没有任何作用,并返回undefined
。
我想我少了些什么。这是我要测试的沙箱代码:
editor.on('cursorActivity', function() {
var options = {
from: editor.getDoc().getCursor(),
to: editor.getDoc().getCursor(),
list: ['foo', 'bar', 'baz']
};
editor.showHint(options);
});
http://jsfiddle.net/3wvcudqt/3/
好的,根据文档,解决了我的问题:
查找提示是通过提示函数(提示选项)完成的,该函数采用编辑器实例和选项对象,并返回{list,from,to}对象
必须从传递到showHint
的hint
函数返回from
、to
和list
,而不是将它们传递给showHint(options)
。
http://jsfiddle.net/3wvcudqt/4/
editor.on('cursorActivity', function() {
var options = {
hint: function() {
return {
from: editor.getDoc().getCursor(),
to: editor.getDoc().getCursor(),
list: ['foo', 'bar']
}
}
};
editor.showHint(options);
});
相关文章:
- curl和fileget_contents在ajax调用后不起作用
- I'我试图在文本区域中进行特定的输入,调用特定的javascript函数,但没有成功;不起作用
- javascript函数调用不起作用
- javascript验证和ajax调用同时不起作用
- Ajax调用不起作用
- 从PHP调用JS函数不起作用
- jQueryAjax调用在单独的.js文件中不起作用
- HtmlBox(jquery插件)在ajax调用中不起作用
- 函数调用不起作用
- jQuery选择ajax调用中附加的元素不起作用
- jQuery调用keyup事件不起作用
- ng显示“;调用方法“;不起作用
- JavaFX+WebView/Javascript:setTimeOut不起作用调用堆栈来自Java
- .ajax调用在chrome中不起作用
- 为什么第二次调用isNaN时它不起作用
- IE9+IE10 AJAX调用不起作用
- 如果在include文件中使用连接,Jquery ajax调用将不起作用
- Angular 1.5变量在调用一次之前不起作用
- Jquery事件绑定获胜'当作为方法调用时不起作用,但当直接在控制台中调用时会起作用
- SPA异步调用在IE 11中不起作用