Issue: `showHint is not a function`
See original GitHub issueHi, I use the following:
- vue: 2.5.3
- vue-codemirror 4.0.5
- vue-electron 1.0.6
With this code:
MyComponent.vue
<template>
<codemirror
ref="vueCodemirror"
v-model="form.query"
@ready="onCodemirrorReady"
@input="onCodemirrorInput"
:options="codemirrorOptions"/>
</template>
<script>
export default {
data () {
return {
codemirrorOptions: {
autofocus: true,
extraKeys: { Ctrl: 'autocomplete' },
line: true,
lineNumbers: true,
mode: 'text/x-mysql',
styleActiveLine: true
},
form: {
query: 'SELECT * FROM `service.billing`.gridSettings;'
}
}
},
computed: {
codemirror () {
return this.$refs.vueCodemirror.codemirror
}
},
methods: {
onCodemirrorReady (cm) {
cm.on('keypress', () => {
cm.showHint()
})
},
onCodemirrorInput (newQuery) {
this.form.query = newQuery
}
}
}
</script>
main.js
import Vue from 'vue'
import App from './App'
import VueCodemirror from 'vue-codemirror'
import 'codemirror/addon/hint/show-hint'
import 'codemirror/addon/hint/show-hint.css'
import 'codemirror/addon/hint/sql-hint.js'
import 'codemirror/addon/selection/active-line.js'
import 'codemirror/mode/sql/sql'
import 'codemirror/lib/codemirror.css'
Vue.use(VueCodemirror)
if (!process.env.IS_WEB) Vue.use(require('vue-electron'))
new Vue({
components: { App },
template: '<App/>'
}).$mount('#app')
What is Expected?
When I type in the codemirror textarea, showHint
function should be called and the hint should be displayed
What is actually happening?
The following error happen: Uncaught TypeError: cm.showHint is not a function
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
CodeMirror custom showHint() call doesn't work - Stack Overflow
Show activity on this post. Attempting to implement a custom showHint call for a spellcheck module. I've followed the docs but calling editor....
Read more >Why autocomplete on codemirror not work alwayes when I ...
so I write : CodeMirror.commands.autocomplete = function(cm) { CodeMirror.showHint(cm, CodeMirror.hint.anyword); }; var editor = CodeMirror.
Read more >API Browser autocomplete is broken - Developing with Prismic
showHint is not a function at CodeMirror.commands.autocomplete ... This thread is being monitored as an open ticket in the issue tracker.
Read more >CodeMirror-Mode-TiddlyWiki5 produces javascript error
showHint is not a function. (In 'e.showHint(i)', 'e.showHint' is undefined) ... I don't know if its your problem but in the past this...
Read more >It says '1' is not a function, but I believe that the Boolean value ...
//Problem: Hints are shown even when form is valid //Solution: Hide and show them at appropriate times var $password = $("#password"); var ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@lihuacai168 You also need to import the show-hint javascript.
@surmon-china