最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - tinyMCE triggerSave not working - Stack Overflow

programmeradmin3浏览0评论

Im trying to submit a form with a tinyMCE textarea. Im submitting the form via javascript, and in order to do this i know you have to call tinyMCE.triggerSave to copy the contents of the editor to the hidden textarea it replaces. For the life of me i can NOT get tinyMCE.triggerSave to do ANYTHING. I know its not because i run the mand from the safari and firefox debug tools and nothing in the DOM changes.

Other than this problem tinyMCE seems to be working fine, the form shows up and works. I just cant submit it.

EDIT: even if i use a standard form submit button it does not pick up the content.

Im trying to submit a form with a tinyMCE textarea. Im submitting the form via javascript, and in order to do this i know you have to call tinyMCE.triggerSave to copy the contents of the editor to the hidden textarea it replaces. For the life of me i can NOT get tinyMCE.triggerSave to do ANYTHING. I know its not because i run the mand from the safari and firefox debug tools and nothing in the DOM changes.

Other than this problem tinyMCE seems to be working fine, the form shows up and works. I just cant submit it.

EDIT: even if i use a standard form submit button it does not pick up the content.

Share Improve this question edited Jun 22, 2010 at 22:57 Michael asked Jun 22, 2010 at 22:45 MichaelMichael 1,0422 gold badges15 silver badges31 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 7

You can also run into this problem if you initialize the same editor twice using tinymce.execCommand('mceAddControl', true, id);

No error will be shown but the triggerSave function will fail silently.

I included the tinyMCE js files twice. I had

= include_tiny_mce_if_needed

in my application template, and i had

- content_for(:head, include_tiny_mce_if_needed)

in my view file ... BAD

Caused me hours of frustration.

It might not just be that you included js files twice. I just ran into a similar issue and did a quick benchtest of it. Approx 1 in 100 times triggerSave() failed silently ... once it fails you're done. It won't work again until you reload/rerun a full tinymce.init()

Moral of the story, don't trust triggerSave()! Sooner or later you will end up losing critical data.

发布评论

评论列表(0)

  1. 暂无评论