I want to use tooltip with codemirror , so I write function to show it and the function work fine ,when I press the button then the function run , my problem is when I call the function using extraKeys (ctrl_R) then the function not run ,this is my try online : my try
this is the code :
var cm = CodeMirror(document.getElementById("editor"), {
value: "function myScript() {\n return 100;\n}",
mode: "javascript",
indentUnit: 4,
lineNumbers: true,
extraKeys: {
"Ctrl-R":function()
{
textMarker = cm.markText({
line: 1,
ch: 4
}, {
line: 1,
ch: 10
}, {
className: 'marked-text'
});
$('.marked-text').tooltip({
title: 'This is a return statement',
container: 'body',
delay: { "show": 500, "hide": 100 },
animation: false
});
}
}
});
var textMarker;
$('#add').click(function() {
textMarker = cm.markText({
line: 1,
ch: 4
}, {
line: 1,
ch: 10
}, {
className: 'marked-text'
});
$('.marked-text').tooltip({
title: 'This is a return statement',
container: 'body',
delay: { "show": 500, "hide": 100 },
animation: false
});
});
$('#remove').click(function() {
if (textMarker) {
textMarker.clear();
}
});
any body can help , what my wrong ?