Skip to content

Commit 51ed7b0

Browse files
committed
[toc2] Initialize toc2 button after cfg is loaded / fix #1249
1 parent 96ab1d4 commit 51ed7b0

File tree

1 file changed

+10
-3
lines changed
  • src/jupyter_contrib_nbextensions/nbextensions/toc2

1 file changed

+10
-3
lines changed

src/jupyter_contrib_nbextensions/nbextensions/toc2/main.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ define([
6363
}
6464
}
6565

66+
function toggleToc() {
67+
toggle_toc(cfg)
68+
}
69+
70+
6671
var toc_button = function(cfg) {
6772
if (!IPython.toolbar) {
6873
events.on("app_initialized.NotebookApp", function (evt) {
@@ -158,6 +163,8 @@ define([
158163
var cfg = toc2.read_config();
159164
// create highlights style section in document
160165
create_additional_css(cfg);
166+
// add toc toggle button (cfg loaded)
167+
toc_button(cfg); //console.log("Adding toc_button")
161168
// call main function with newly loaded config
162169
table_of_contents(cfg);
163170
// event: render toc for each markdown cell modification
@@ -175,7 +182,7 @@ define([
175182
addSaveAsWithToc();
176183
})
177184

178-
// add a save as HTML with toc included
185+
// add a save as HTML with toc included
179186
addSaveAsWithToc();
180187
// Highlight cell on execution
181188
patch_CodeCell_get_callbacks()
@@ -184,11 +191,11 @@ define([
184191

185192
var load_ipython_extension = function() {
186193
load_css(); //console.log("Loading css")
187-
toc_button(); //console.log("Adding toc_button")
194+
// toc_button(); //console.log("Adding toc_button")
188195

189196
// Wait for the notebook to be fully loaded
190197
if (Jupyter.notebook !== undefined && Jupyter.notebook._fully_loaded) {
191-
// this tests if the notebook is fully loaded
198+
// this tests if the notebook is fully loaded
192199
console.log("[toc2] Notebook fully loaded -- toc2 initialized ")
193200
toc_init();
194201
} else {

0 commit comments

Comments
 (0)