Move initial CKEditor code to function and run it when '#container' ready.
This commit is contained in:
parent
47dc1824da
commit
6f4f59655a
|
@ -14,18 +14,7 @@
|
|||
(function($) {
|
||||
// CMS.$ will be passed for $
|
||||
$(document).ready(function () {
|
||||
// get the container id
|
||||
var container = 'id_{{ name }}';
|
||||
var prefixPos = container.indexOf('-__prefix__');
|
||||
if (prefixPos != - 1) {
|
||||
// in case the textarea is in an inline, we need to perform some replacements
|
||||
var name = container.substring(0, prefixPos);
|
||||
var replacement = $('#' + name + "-TOTAL_FORMS").val();
|
||||
container = container.replace('__prefix__', replacement);
|
||||
}
|
||||
|
||||
// initialize ckeditor only if the container exists and is ready
|
||||
$('#'+container).ready(function() {
|
||||
function initCKEditor(container) {
|
||||
CMS.CKEditor.init(container, {{ settings|safe }}, {
|
||||
'static_url': '{{ STATIC_URL }}',{% if placeholder %}
|
||||
'add_plugin_url': '{{ placeholder.get_add_url }}',
|
||||
|
@ -51,6 +40,21 @@ $(document).ready(function () {
|
|||
'toolbar': 'HTMLField'
|
||||
{% endif %}
|
||||
});
|
||||
}
|
||||
|
||||
// get the container id
|
||||
var container = 'id_{{ name }}';
|
||||
var prefixPos = container.indexOf('-__prefix__');
|
||||
if (prefixPos != - 1) {
|
||||
// in case the textarea is in an inline, we need to perform some replacements
|
||||
var name = container.substring(0, prefixPos);
|
||||
var replacement = $('#' + name + "-TOTAL_FORMS").val();
|
||||
container = container.replace('__prefix__', replacement);
|
||||
}
|
||||
|
||||
// initialize ckeditor only if the container exists and is ready
|
||||
$('#'+container).ready(function() {
|
||||
initCKEditor(container);
|
||||
});
|
||||
});
|
||||
})(CMS.$);
|
||||
|
|
Reference in New Issue