JSFiddle in here, this is a JavaScript and/or CodeMirror question.
In the below snippet, hint
function is defined as a property in hintOptions
object.
Is there a possibility to set a property of that function, without defining it outside the code block?
var editor = CodeMirror.fromTextArea(myTextarea, {
hintOptions: {
hint: function(cm, callback, options) {
return {
}
}
}
});
I tried with anonymous function, as in:
var editor = CodeMirror.fromTextArea(myTextarea, {
hintOptions: {
hint: (function(cm, callback, options) {
return {
}
})({
async: true
})
}
});
but it seems to be a syntax error, since the JavaScript doesn't work at all.
As CodeMirror docs mention:
hint: function
A hinting function, as specified above. It is possible to set the
async
property on a hinting function to true, in which case it will be called with arguments (cm, callback, ?options)
To check if async
is correctly set:
- Open the JSFiddle
- Click on the 'class code'
- Type Ctrl+Space
- The
log
textarea should have notundefined
async
property. – Ahmed Ashourhint: async function...
– charlietfl