Set $ to django.jQuery if $ not defined, organize ckeditor-init.js, replace .click(...) with delegated .on(...) in case elements do not exist when code is run
This commit is contained in:
parent
7efe190d02
commit
d441e27239
|
@ -1,20 +1,23 @@
|
|||
$(function() {
|
||||
;(function() {
|
||||
var $ = $ || django.jQuery;
|
||||
$(function() {
|
||||
initialiseCKEditor();
|
||||
initialiseCKEditorInInlinedForms();
|
||||
|
||||
function initialiseCKEditorInInlinedForms() {
|
||||
$(".add-row a, .grp-add-handler").click(function () {
|
||||
initialiseCKEditor();
|
||||
return true;
|
||||
});
|
||||
$(document).on("click", ".add-row a, .grp-add-handler", function () {
|
||||
initialiseCKEditor();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function initialiseCKEditor() {
|
||||
$('textarea[data-type=ckeditortype]').each(function(){
|
||||
function initialiseCKEditor() {
|
||||
$('textarea[data-type=ckeditortype]').each(function(){
|
||||
if($(this).data('processed') == "0" && $(this).attr('id').indexOf('__prefix__') == -1){
|
||||
$(this).data('processed',"1");
|
||||
CKEDITOR.replace($(this).attr('id'), $(this).data('config'));
|
||||
$(this).data('processed',"1");
|
||||
CKEDITOR.replace($(this).attr('id'), $(this).data('config'));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
}());
|
||||
|
|
Loading…
Reference in New Issue