zoukankan      html  css  js  c++  java
  • 如何获取tinyeditor编辑器里面的值

    tinyeditor个人感觉适用于基本文本信息的编辑,即学即用。

    你创建编辑器的时候:

    <textarea name="input" id="input" style="400px; height:200px"></textarea>
    var instance = new TINY.editor.edit(....);

    实例如:

    new TINY.editor.edit(editor,{
    id:input,
    584,
    height:175,.....

    在提交表单的时候或者表单验证通过之后需要调用:instance.post();

    当实例对象不会被使用后,系统后自动回收的,将对象置为null, 干掉所有与对象相关的引用
    注意:instance.post(); 中“instance”汉译为实例的意思,也即上方名称“editor”,在表单验证时的调用则为:editor.post();

    new TINY.editor.edit(editor,{
    id:input,
    584,
    height:175,.....

    这样就会取到最新更新的值。

    看看代码,解析一下:

    需要提交的时候 必须调用 编辑器变量 也就是 edit 方法的第一个参数,的post方法来将值塞到你传入的那个 textarea 里面去, 然后再取得里面的值...

    <?php
    // 加载对应的css/js文件
    $this->stylesheet_link_tag(
        "{$__requestdir__}static/themes/default/js",
        DOCROOT . '/static/themes/default/js',array(
            'tinyeditor/style'
        )
    );
    $this->js_include_tag(
        "{$__requestdir__}static/themes/default/js",
        DOCROOT . '/static/themes/default/js',array(
            'tinyeditor/core'
        )
    );
    ?>
    <script type="text/javascript">
    new TINY.editor.edit('editor_<?php echo $id; ?>',{
        id:'<?php echo $id; ?>',
         584,
        height: 175,
        cssclass:'te',
        controlclass:'tecontrol',
        rowclass:'teheader',
        dividerclass:'tedivider',
        controls:['bold','italic','underline','strikethrough','|','subscript','superscript','|',
                  'orderedlist','unorderedlist','|','outdent','indent','|','leftalign',
                  'centeralign','rightalign','blockjustify','|','unformat','|','undo','redo','n',
                  'font','size','style','|','image','hr','link','unlink','|','cut','copy','paste','print'],
        footer:true,
        fonts:['Verdana','Arial','Georgia','Trebuchet MS'],
        xhtml:true,
        css: '#<?php echo $id; ?> {border:none; margin:0; padding:0; font:14px "Courier New",Verdana; border:0} #editor_<?php echo $id; ?> {cursor:text; margin:10px} ',
        bodyid:'te_c<?php echo $id; ?>',
        footerclass:'tefooter',
        toggle:{text:'source',activetext:'wysiwyg',cssclass:'toggle'},
        resize:{cssclass:'resize'}
    });
    window.get_<?php echo $id; ?>_content = function (){
        editor_<?php echo $id; ?>.post();
        return T$('<?php echo $id; ?>').value;
    };
    </script>

    代码为:

    editor.post();
    var textAreaHtml = editor.t.value;

    也可以用别的方法来得到该值

  • 相关阅读:
    [LeetCode]1290. 二进制链表转整数
    [LeetCode]1295. 统计位数为偶数的数字
    map 用法 拿到map数组每一个数据
    父子组件相互传参
    父组件给子组件传参 el-dialog 试例
    如何用JS判断div中内容为空,当为空时隐藏div
    完整的Vue+element-ui table组件实现表格内容的编辑删除和新行添加小实例
    Git操作
    charles的使用
    移动端的一些问题
  • 原文地址:https://www.cnblogs.com/tv151579/p/3081062.html
Copyright © 2011-2022 走看看