當主題改變時,我想舉辦一個活動。不使用setTheme()。
var editor = ace.edit("editor");
ace.require("ace/ext/settings_menu").init(editor);
editor.session.setMode("ace/mode/java");
editor.setOptions({
theme: "ace/theme/tomorrow_night_bright"
});
editor.on('changeTheme', function() { -> This is not working
console.log(editor.mode)
})
我嘗試更改主題事件,並且使用 $("#-theme").change() 事件但不起作用
editor.renderer 上有 themeChange 和 themeLoaded 事件,請參閱 https://github.com/ajaxorg/ace/blob/31bbd6ade094c1e142565837a4ee93c7931399a4c1e142565837a4ee93c7931399a4/src#virtual_
editor.renderer.on('themeChange', function() { // theme setting changed }) editor.renderer.on('themeLoaded', function() { // theme loaded and applied to editor })