简体   繁体   English

捕获TinyMCE表单文本区域

[英]capturing TinyMCE form textarea

I've been unable to get the value of a TinyMCE textarea, I just cant get the value from it? 我一直无法获得TinyMCE textarea的价值,我只是无法从中获得价值?

This is my form (oh so simple): 这是我的表格(很简单):

<div id="pow_form_container">
    <form id="pow_content_form">        
        <textarea name="pow_content" id="tiny" style="width:100%">
            <? echo $pow; ?>
        </textarea>
        <input type="hidden" id="pow" name="pow" />
    </form>
</div>

And this is the JQuery ive been using to tray and get the content of the editor 这是JQuery ive用来托盘化并获取编辑器内容的

    save_pow: function (job_id) {
        var editor = tinymce.get("tiny"),content = editor.getContent();
        $.post('/jobs/save_pow/' + job_id, $('#pow_content_form').serialize(), function (response) {

            alert(content);

            if (response.status == 'ok') {
                tinymce.EditorManager.execCommand('mceRemoveEditor',true, "tiny");
                Common_UI.dialog_close('edit_pow_dialog');

            }
        });
    },  

But what gets posted is : 但是得到的是:

pow_content=++++%09%09++++%09&pow=

WTF is that? WTF是吗?

I've tried things like: 我已经尝试过类似的事情:

tinyMCE.triggerSave();

SO 所以

save_pow: function (job_id) {
    tinyMCE.triggerSave();
    $.post('/jobs/save_pow/' + job_id, $('#pow_content_form').serialize(), function (response) {

        if (response.status == 'ok') {
            Common_UI.dialog_close('edit_pow_dialog');

        }
    });
},

But that doesn't change anything, how can it be this hard? 但这并没有改变任何东西,怎么会很难呢? Have a missed something? 错过了什么吗?

I am initializing tinyMCE with this as the text editor is on a jquery UI popup dialog and its the only way I could get the editor to show: edit_pow: function (job_id) { $.get('/jobs/edit_pow/' + job_id, function (data) { 我正在使用它初始化tinyMCE,因为文本编辑器位于jquery UI弹出对话框中,这是我可以使编辑器显示的唯一方法:edit_pow:function(job_id){$ .get('/ jobs / edit_pow /'+ job_id ,功能(数据){

            Common_UI.dialog('edit_pow_dialog', 'Edit Programme of Works', data, {
                'Save': function () {
                    method.jobs.save_pow(job_id);
                }
            });
            tinyMCE.init({ selector:'#tiny' });

        });
    },

You can get the content of the editor with getContent() : 您可以使用getContent()获得编辑器的内容:

var editor = tinymce.get("tiny"),
    content = editor.getContent();

You should also be aware that you cannot re-init tinyMCE without destroying any previous instances (see this answer ). 您还应该注意,您必须在不破坏任何先前实例的情况下重新初始化tinyMCE(请参阅此答案 )。 So before the dialog_close you should remove the tinyMCE instance: 因此,在dialog_close之前,您应该删除tinyMCE实例:

tinymce.EditorManager.execCommand('mceRemoveEditor',true, "tiny");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM