jquery 主题改变时,我如何制作事件

xoefb8l8  于 2023-08-04  发布在  jQuery
关注(0)|答案(1)|浏览(94)

当主题改变时,我想做一个事件。不要使用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()事件,但不工作

mtb9vblg

mtb9vblg1#

editor.renderer上有themeChange和themeLoaded事件,请参阅https://github.com/ajaxorg/ace/blob/31bbd6ade094c1e142565837a4ee93c7931399a4/src/virtual_renderer.js#L1721

editor.renderer.on('themeChange', function() {
    // theme setting changed
})
editor.renderer.on('themeLoaded', function() {
    // theme loaded and applied to editor
})

字符串

相关问题