@@ -20,15 +20,25 @@ var blockId = 'block0';
2020require ( [ 'gitbook' , 'jQuery' ] , function ( gitbook , $ ) {
2121
2222 gitbook . events . bind ( "start" , function ( e , config ) {
23- var conf = config || { } ;
23+ var conf = config || { "ai2:blocks" : { } } ;
2424 TEXT_WHEN = conf [ 'ai2-blocks' ] [ 'text_when' ] || TEXT_WHEN ;
2525 TEXT_DO = conf [ 'ai2-blocks' ] [ 'text_do' ] || TEXT_DO ;
2626 TEXT_CALL = conf [ 'ai2-blocks' ] [ 'text_call' ] || TEXT_CALL ;
2727 TEXT_SET = conf [ 'ai2-blocks' ] [ 'text_set' ] || TEXT_SET ;
2828 SCALE_LEVEL = conf [ 'ai2-blocks' ] [ 'scale_level' ] || SCALE_LEVEL ;
29-
29+
30+ render ( ) ;
31+ } ) ;
32+
33+ gitbook . events . bind ( "page.change" , function ( ) {
34+ render ( ) ;
35+ } )
36+ } ) ;
37+
38+ function render ( ) {
3039 // METHOD
31- $ ( 'div[ai2-method]' ) . each ( function ( ) {
40+ $ ( 'div[ai2-method]' ) . filter ( "[not-rendered]" ) . each ( function ( ) {
41+ $ ( this ) . removeAttr ( "not-rendered" ) ;
3242 var block = getBlock ( decodeURI ( $ ( this ) . attr ( "value" ) ) ) ;
3343
3444 var name = block [ 'name' ] ;
@@ -61,7 +71,8 @@ require(['gitbook', 'jQuery'], function(gitbook, $) {
6171 } ) ;
6272
6373 // EVENT
64- $ ( 'div[ai2-event]' ) . each ( function ( ) {
74+ $ ( 'div[ai2-event]' ) . filter ( "[not-rendered]" ) . each ( function ( ) {
75+ $ ( this ) . removeAttr ( "not-rendered" ) ;
6576 var block = getBlock ( decodeURI ( $ ( this ) . attr ( "value" ) ) ) ;
6677
6778 var name = block [ 'name' ] ;
@@ -93,7 +104,8 @@ require(['gitbook', 'jQuery'], function(gitbook, $) {
93104 } ) ;
94105
95106 // PROPERTY
96- $ ( 'div[ai2-property]' ) . each ( function ( ) {
107+ $ ( 'div[ai2-property]' ) . filter ( "[not-rendered]" ) . each ( function ( ) {
108+ $ ( this ) . removeAttr ( "not-rendered" ) ;
97109 var block = getBlock ( decodeURI ( $ ( this ) . attr ( "value" ) ) ) ;
98110
99111 var name = block [ 'name' ] ;
@@ -127,8 +139,7 @@ require(['gitbook', 'jQuery'], function(gitbook, $) {
127139
128140 newBlockAndWorkspace ( blockId , scale ) ;
129141 } ) ;
130- } ) ;
131- } ) ;
142+ }
132143
133144/**
134145 * return a required block
0 commit comments