Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ckeditor #83

Open
praad opened this issue Sep 24, 2018 · 1 comment
Open

Ckeditor #83

praad opened this issue Sep 24, 2018 · 1 comment

Comments

@praad
Copy link

praad commented Sep 24, 2018

If the dynamic part of the form contains ckeditor it wont save correctly.

Here is a fix for ModalRemote.js
`
/**
* Prepare submit button when modal has form
* @param {string} modalForm
* @param {object} modalFormSubmitBtn
*/
this.setupFormSubmit = function (modalForm, modalFormSubmitBtn) {

    if (modalFormSubmitBtn === undefined) {
        // If submit button not found throw warning message
        console.warn('Modal has form but does not have a submit button');
    } else {
        var instance = this;

        // Submit form when user clicks submit button
        $(modalFormSubmitBtn).click(function (e) {
            var data;
            console.log('KAKI:', CKEDITOR.instances);
            
            // Update all instance of CKEDITOR for ajax submit.
            for (var i in CKEDITOR.instances) {
                CKEDITOR.instances[i].updateElement() 
            }

            // Test if browser supports FormData which handles uploads
            if (window.FormData) {
                //console.log($(modalForm));
                data = new FormData($(modalForm)[0]);
            } else {
                // Fallback to serialize
                data = $(modalForm).serializeArray();
            }

            // Send the form to server by ajax:
            instance.doRemote(
                $(modalForm).attr('action'),
                $(modalForm).hasAttr('method') ? $(modalForm).attr('method') : 'GET',
                data
            );
        });
    }
};

`

@Er-Kalpesh
Copy link
Collaborator

great please can you create a pull request so we can pass this solution and that will be helpful to others

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants