Tinymce 3 - 在自定义按钮点击后在新块中插入新内容

时间:2017-04-14 12:06:24

标签: javascript jquery tinymce-3

我想问一下是否有可能在最近添加的内容之外添加新内容。 所以,我有自定义按钮,添加一些简单的HTML。 我想要存档的是添加相同的html但在现有的html之外,所以在我的屏幕截图上标记为绿色。我正在寻找一种方法如何从这个div中逃脱,并在现有的之后添加新的html。

下面的截图和代码 - 如何生成javascript按钮 - 非常简单。

感谢您的建议。 enter image description here

var oferta = '<div class="col-sm-3"><h1>test</h1></div>'
setup: function (ed) {
        ed.addButton('example', {
            title: 'example.desc',
            image: './/',
            text: 'Oferta',
            icon: true,
            onclick: function () {
                tinyMCE.execCommand('mceInsertContent', false, oferta);
            }
        });
    },

编辑:当我连续按3次按钮时,现在看起来如何。(每个下一个内容都会添加到现有内容中。) enter image description here

1 个答案:

答案 0 :(得分:1)

使用此示例尝试更改代码非常容易。

Ign http://deb.debian.org jessie InRelease
Ign http://ppa.launchpad.net trusty InRelease
Ign http://deb.debian.org jessie-updates InRelease
Err http://deb.debian.org jessie Release.gpg
Cannot initiate the connection to 8080:80 (0.0.31.144). - connect (22: Invalid argument)
Err http://ppa.launchpad.net trusty Release.gpg
Cannot initiate the connection to 8080:80 (0.0.31.144). - connect (22: Invalid argument)
Ign http://security.debian.org jessie/updates InRelease
Err http://deb.debian.org jessie-updates Release.gpg
Cannot initiate the connection to 8080:80 (0.0.31.144). - connect (22: Invalid argument)
Err http://security.debian.org jessie/updates Release.gpg
Cannot initiate the connection to 8080:80 (0.0.31.144). - connect (22: Invalid argument)
Ign http://ppa.launchpad.net trusty Release
Ign http://security.debian.org jessie/updates Release
Err http://ppa.launchpad.net trusty/main amd64 Packages

Err http://security.debian.org jessie/updates/main amd64 Packages

Err http://ppa.launchpad.net trusty/main amd64 Packages

Ign http://deb.debian.org jessie Release
Err http://security.debian.org jessie/updates/main amd64 Packages

Err http://ppa.launchpad.net trusty/main amd64 Packages

Err http://ppa.launchpad.net trusty/main amd64 Packages

Ign http://deb.debian.org jessie-updates Release
Err http://security.debian.org jessie/updates/main amd64 Packages

Err http://security.debian.org jessie/updates/main amd64 Packages

Err http://ppa.launchpad.net trusty/main amd64 Packages
Cannot initiate the connection to 8080:80 (0.0.31.144). - connect (22: Invalid argument)
Err http://security.debian.org jessie/updates/main amd64 Packages
Cannot initiate the connection to 8080:80 (0.0.31.144). - connect (22: Invalid argument)
Err http://deb.debian.org jessie/main amd64 Packages
Cannot initiate the connection to 8080:80 (0.0.31.144). - connect (22: Invalid argument)
Err http://deb.debian.org jessie-updates/main amd64 Packages
Cannot initiate the connection to 8080:80 (0.0.31.144). - connect (22: Invalid argument)
W: Failed to fetch http://deb.debian.org/debian/dists/jessie/Release.gpg  
Cannot initiate the connection to 8080:80 (0.0.31.144). - connect (22: Invalid argument)

W: Failed to fetch http://ppa.launchpad.net/zfs-native/stable/ubuntu/dists/trusty/Release.gpg  Cannot initiate the connection to 8080:80 (0.0.31.144). - connect (22: Invalid argument)

W: Failed to fetch http://deb.debian.org/debian/dists/jessie-updates/Release.gpg  Cannot initiate the connection to 8080:80 (0.0.31.144). - connect (22: Invalid argument)

W: Failed to fetch http://security.debian.org/dists/jessie/updates/Release.gpg  Cannot initiate the connection to 8080:80 (0.0.31.144). - connect (22: Invalid argument)

W: Failed to fetch http://ppa.launchpad.net/zfs-native/stable/ubuntu/dists/trusty/main/binary-amd64/Packages  Cannot initiate the connection to 8080:80 (0.0.31.144). - connect (22: Invalid argument)

W: Failed to fetch http://security.debian.org/dists/jessie/updates/main/binary-amd64/Packages  Cannot initiate the connection to 8080:80 (0.0.31.144). - connect (22: Invalid argument)

W: Failed to fetch http://deb.debian.org/debian/dists/jessie/main/binary-amd64/Packages  Cannot initiate the connection to 8080:80 (0.0.31.144). - connect (22: Invalid argument)

W: Failed to fetch http://deb.debian.org/debian/dists/jessie-updates/main/binary-amd64/Packages  Cannot initiate the connection to 8080:80 (0.0.31.144). - connect (22: Invalid argument)

E: Some index files failed to download. They have been ignored, or old ones used instead.