Toms Tilgalis
Toms Tilgalis

Reputation: 11

CKEditor jQuery doesn't send POST data

I ha ve dynamic page loading and in page there is links which each opens editing form with CKEditor

My JavaScript function for calling those forms:

function editProduct(id) {
    $("#add-product").hide();
    if (CKEDITOR.instances['editor']) {
        CKEDITOR.remove(CKEDITOR.instances['editor']);
    }
    $("#edit-product").load(homeurl+"/admin/edit/product",{id:id},function(){
        $.getScript(homeurl+"/js/jquery.MultiFile.js");
        $("#edit-product").find("#editor").ckeditor();
        $("#edit-product").show();
    });
}

so there i destroy CKEditor instance if one exists. On the forst page load and opening form everything goes as it should, but when i click other link after opening editing form so it would open another section it shows CKEditor but doesn't send POST data. I don't use jQuery to send data. I pass data to iframe like this:

<form action="/admin/add/product" enctype="multipart/form-data" method="post" target="upload_iframe">

after sending data i refresh dynamic content with this JavaScript function ( which also checks for editor instances and destroy them )

function showPage(page) {
    act_page = page;
    $("#dynamic-content").load(homeurl+"/admin/getpage",{page:page},function(){
        if (CKEDITOR.instances['editor']) { 
            CKEDITOR.remove(CKEDITOR.instances['editor']); 
        }
        $('html,body').find('#editor').ckeditor();
    });
}

Upvotes: 0

Views: 1137

Answers (1)

Reinmar
Reinmar

Reputation: 22023

so there i destroy CKEditor instance if one exists.

Nope, you're not destroying editor. Use editor.destroy() method instead of private CKEDITOR.remove which only does part of a cleanup job.

You should have:

if (CKEDITOR.instances.editor) {
    CKEDITOR.instances.editor.destroy();
}

Upvotes: 1

Related Questions