LoginSignup
2
0

More than 3 years have passed since last update.

Sortable + TinyMCE

Posted at

困ったこと

TinyMCE が含まれる要素を並び替えした場合に、TinyMCE の iframe の中が空になってしまう。

使用したライブラリ

Sortable のベーシックな記述方法

並び替え要素に TinyMCE が含まれていなければ問題ない。

var options = {
    handle: '.js-cursor-move',
};
u('.js-sortable').each(function(elem){
    Sortable.create(elem, options);
});

並び替え要素に TinyMCE が含まれている場合の書き方

並び替え開始時に TinyMCE を解除して、並び替え完了時に TinyMCE を再設定する。

var options = {
    handle: '.js-cursor-move',
    onStart: function(evt) {
        u(evt.item).find('.js-wysiwyg-editor').each(function(elem){
            tinyMCE.execCommand('mceRemoveEditor', false, u(elem).attr('id'));
        });
    },
    onEnd: function(evt) {
        u(evt.item).find('.js-wysiwyg-editor').each(function(elem){
            tinyMCE.execCommand('mceAddEditor', true, u(elem).attr('id'));
        });
    },
};
u('.js-sortable').each(function(elem){
    Sortable.create(elem, options);
});
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0