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

Slow loading multiple CKEditors #8

Closed
pavlinter opened this issue Jan 8, 2015 · 0 comments
Closed

Slow loading multiple CKEditors #8

pavlinter opened this issue Jan 8, 2015 · 0 comments

Comments

@pavlinter
Copy link

У меня загружается много редакторов!
Можно ли как то ускорить загрузку?
Предлагаю свой вариант:
Инициализировать при событии, например focus на textarea

// mihaildev\ckeditor\CKEditor

public $initOnEvent = false; //"focus"

public function run()
{
    .....
    if($this->_inline){
        $JavaScript = "CKEDITOR.inline(";
        $JavaScript .= Json::encode($this->options['id']);
        $JavaScript .= empty($this->editorOptions) ? '' : ', '.Json::encode($this->editorOptions);
        $JavaScript .= ");";
        $this->getView()->registerCss('#'.$this->containerOptions['id'].', #'.$this->containerOptions['id'].' .cke_textarea_inline{height: '.$this->editorOptions['height'].'px;}');
    }else{
        $JavaScript = "CKEDITOR.replace(";
        $JavaScript .= Json::encode($this->options['id']);
        $JavaScript .= empty($this->editorOptions) ? '' : ', '.Json::encode($this->editorOptions);
        $JavaScript .= ");";
    }
    if ($this->initOnEvent) {
        $JavaScript = 'jQuery("#'.$this->options['id'].'").one("' . $this->initOnEvent . '", function(){' . $JavaScript . '});';
        JqueryAsset::register($this->getView());
    }
    $this->getView()->registerJs($JavaScript, View::POS_END);
}
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