admin管理员组文章数量:1399974
I'm using TinyMCE 4.1.10 to enable inline editing on several divs on a page. Everything works fine on initial page load, but if I tear down the editors and rebind the textareas in an ajax call TinyMCE won't hook back up to them. The binding is done with Knockout.
Here is the function that initially loads the data, and also gets called when a refresh occurs.
this.loadLetterFields = function () {
var editors = $("div.editable");
for (var i = editors.length - 1; i > -1; i--) {
var ed_id = editors[i].id;
tinymce.execCommand("mceRemoveEditor", false, ed_id);
}
$.getJSON(_this.fieldURL + "/" + _this.letterId() + "/" + _this.clientId() + "/" + _this.caseId(), function (data) {
for (var i = 0; i < data.length; i++) {
// Reload fields
}
});
tinymce.init({
selector: "div.editable",
inline: true,
menubar: false,
statusbar: false,
toolbar: "bold italic underline | alignleft aligncenter alignright | bullist numlist outdent indent",
forced_root_block: false
});
};
I've pieced what I have together from several SO posts, but this seems to be a recurring issue. Are there any solutions? Is this a known bug?
Update: I just noticed that it doesn't seem to be all of the divs, but there is not difference in the divs that are working and the ones that aren't. They are all generated by the same ko if binding.
I'm using TinyMCE 4.1.10 to enable inline editing on several divs on a page. Everything works fine on initial page load, but if I tear down the editors and rebind the textareas in an ajax call TinyMCE won't hook back up to them. The binding is done with Knockout.
Here is the function that initially loads the data, and also gets called when a refresh occurs.
this.loadLetterFields = function () {
var editors = $("div.editable");
for (var i = editors.length - 1; i > -1; i--) {
var ed_id = editors[i].id;
tinymce.execCommand("mceRemoveEditor", false, ed_id);
}
$.getJSON(_this.fieldURL + "/" + _this.letterId() + "/" + _this.clientId() + "/" + _this.caseId(), function (data) {
for (var i = 0; i < data.length; i++) {
// Reload fields
}
});
tinymce.init({
selector: "div.editable",
inline: true,
menubar: false,
statusbar: false,
toolbar: "bold italic underline | alignleft aligncenter alignright | bullist numlist outdent indent",
forced_root_block: false
});
};
I've pieced what I have together from several SO posts, but this seems to be a recurring issue. Are there any solutions? Is this a known bug?
Update: I just noticed that it doesn't seem to be all of the divs, but there is not difference in the divs that are working and the ones that aren't. They are all generated by the same ko if binding.
Share Improve this question edited Jul 8, 2015 at 21:35 Devin Goble asked Jul 7, 2015 at 15:43 Devin GobleDevin Goble 2,8974 gold badges32 silver badges45 bronze badges1 Answer
Reset to default 8I ran into a similar issue. My solution was to call tinyMCE.remove();
before calling the reload. Then tinyMCE.init();
would work as expected.
本文标签: javascriptTinyMCE init fails after ajax refreshStack Overflow
版权声明:本文标题:javascript - TinyMCE init fails after ajax refresh - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744228124a2596193.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论