@@ -20,15 +20,25 @@ var blockId = 'block0';
20
20
require ( [ 'gitbook' , 'jQuery' ] , function ( gitbook , $ ) {
21
21
22
22
gitbook . events . bind ( "start" , function ( e , config ) {
23
- var conf = config || { } ;
23
+ var conf = config || { "ai2:blocks" : { } } ;
24
24
TEXT_WHEN = conf [ 'ai2-blocks' ] [ 'text_when' ] || TEXT_WHEN ;
25
25
TEXT_DO = conf [ 'ai2-blocks' ] [ 'text_do' ] || TEXT_DO ;
26
26
TEXT_CALL = conf [ 'ai2-blocks' ] [ 'text_call' ] || TEXT_CALL ;
27
27
TEXT_SET = conf [ 'ai2-blocks' ] [ 'text_set' ] || TEXT_SET ;
28
28
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 ( ) {
30
39
// METHOD
31
- $ ( 'div[ai2-method]' ) . each ( function ( ) {
40
+ $ ( 'div[ai2-method]' ) . filter ( "[not-rendered]" ) . each ( function ( ) {
41
+ $ ( this ) . removeAttr ( "not-rendered" ) ;
32
42
var block = getBlock ( decodeURI ( $ ( this ) . attr ( "value" ) ) ) ;
33
43
34
44
var name = block [ 'name' ] ;
@@ -61,7 +71,8 @@ require(['gitbook', 'jQuery'], function(gitbook, $) {
61
71
} ) ;
62
72
63
73
// EVENT
64
- $ ( 'div[ai2-event]' ) . each ( function ( ) {
74
+ $ ( 'div[ai2-event]' ) . filter ( "[not-rendered]" ) . each ( function ( ) {
75
+ $ ( this ) . removeAttr ( "not-rendered" ) ;
65
76
var block = getBlock ( decodeURI ( $ ( this ) . attr ( "value" ) ) ) ;
66
77
67
78
var name = block [ 'name' ] ;
@@ -93,7 +104,8 @@ require(['gitbook', 'jQuery'], function(gitbook, $) {
93
104
} ) ;
94
105
95
106
// PROPERTY
96
- $ ( 'div[ai2-property]' ) . each ( function ( ) {
107
+ $ ( 'div[ai2-property]' ) . filter ( "[not-rendered]" ) . each ( function ( ) {
108
+ $ ( this ) . removeAttr ( "not-rendered" ) ;
97
109
var block = getBlock ( decodeURI ( $ ( this ) . attr ( "value" ) ) ) ;
98
110
99
111
var name = block [ 'name' ] ;
@@ -127,8 +139,7 @@ require(['gitbook', 'jQuery'], function(gitbook, $) {
127
139
128
140
newBlockAndWorkspace ( blockId , scale ) ;
129
141
} ) ;
130
- } ) ;
131
- } ) ;
142
+ }
132
143
133
144
/**
134
145
* return a required block
0 commit comments