Skip to content

Commit 4ddb0fe

Browse files
author
Damien Jones
committed
When explicitely constructing the markdown editor the options should be passed in.
1 parent dbdab01 commit 4ddb0fe

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/angular-markdown-editor.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)