Skip to content

Commit b5848e4

Browse files
authored
Merge pull request #19 from DGJones/master
Completed fix for issue #17
2 parents da4613e + 4ddb0fe commit b5848e4

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/angular-markdown-editor.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ angular
1111
if (! element.hasClass('processed')) {
1212
element.addClass('processed');
1313

14-
// Setup the markdown WYSIWYG.
15-
element.markdown({
14+
var markdownOptions = {
1615
autofocus: options.autofocus || false,
1716
saveable: options.saveable || false,
1817
savable: options.savable || false,
@@ -63,7 +62,17 @@ angular
6362
runScopeFunction(scope, attrs.onShow, e);
6463
}
6564
}
66-
});
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+
}
6776
}
6877
}
6978
};

0 commit comments

Comments
 (0)