@@ -11,14 +11,7 @@ angular
1111 if ( ! element . hasClass ( 'processed' ) ) {
1212 element . addClass ( 'processed' ) ;
1313
14- // if the directive was called after document.ready, e.g. because of ng-if then the element
15- // will not have been initialized by bootstrap-markdown
16- if ( element . markdown === undefined ) {
17- element . data ( 'markdown' , ( data = new $ . fn . markdown . Constructor ( element [ 0 ] , { } ) ) )
18- }
19-
20- // Setup the markdown WYSIWYG.
21- element . markdown ( {
14+ var markdownOptions = {
2215 autofocus : options . autofocus || false ,
2316 saveable : options . saveable || false ,
2417 savable : options . savable || false ,
@@ -69,7 +62,17 @@ angular
6962 runScopeFunction ( scope , attrs . onShow , e ) ;
7063 }
7164 }
72- } ) ;
65+ } ;
66+
67+ // Setup the markdown WYSIWYG.
68+
69+ // if the markdown editor was added dynamically the markdown function will be undefined
70+ // so it has to be called explicitely
71+ if ( element . markdown === undefined ) {
72+ element . data ( 'markdown' , ( data = new $ . fn . markdown . Constructor ( element [ 0 ] , markdownOptions ) ) )
73+ } else {
74+ element . markdown ( markdownOptions ) ;
75+ }
7376 }
7477 }
7578 } ;
0 commit comments