【问题标题】:remove contenteditable="true" on div and create textbox instead with jQuery删除 div 上的 contenteditable="true" 并使用 jQuery 创建文本框
【发布时间】:2011-06-30 03:57:22
【问题描述】:

在 SharePoint 博客网站上,用户通过在 contenteditable 设置为 true 的 div 中键入内容来插入新帖子。这在 iPad 上不起作用,因为 iPad 上的 Safari 不支持它。

我可以找到 div 并删除属性,但是,我将如何插入文本?我可以用多行文本框替换整个 div(但不确定 SharePoint 在保存时对此有何看法)?

HTML 看起来像:

<tr>
    <td nowrap="true" valign="top" width="190px" class="ms-formlabel">
        <h3 class="ms-standardheader">
        <nobr>Body</nobr>
        </h3>
    </td>
    <td valign="top" class="ms-formbody">
        <!-- FieldName="Body"
             FieldInternalName="Body"
             FieldType="SPFieldNote"
        -->
        <span dir="none"><div class='ms-rtestate-field ms-rtefield' style=''><div id='ctl00_m_g_cc0fae80_c5f8_428c_9d00_793718f1d202_ctl00_ctl04_ctl01_ctl00_ctl00_ctl04_ctl00_ctl00_TextField_inplacerte_label' style='display:none'>Rich text editor</div><div class=' ms-rtestate-write ms-rteflags-0' id='ctl00_m_g_cc0fae80_c5f8_428c_9d00_793718f1d202_ctl00_ctl04_ctl01_ctl00_ctl00_ctl04_ctl00_ctl00_TextField_inplacerte' style='min-height:210px' aria-labelledby='ctl00_m_g_cc0fae80_c5f8_428c_9d00_793718f1d202_ctl00_ctl04_ctl01_ctl00_ctl00_ctl04_ctl00_ctl00_TextField_inplacerte_label'  contentEditable='true' ></div><div style="clear:both;"></div></div>
            <span dir="ltr">            
                <input name="ctl00$m$g_cc0fae80_c5f8_428c_9d00_793718f1d202$ctl00$ctl04$ctl01$ctl00$ctl00$ctl04$ctl00$ctl00$TextField_spSave" type="HIDDEN" id="ctl00_m_g_cc0fae80_c5f8_428c_9d00_793718f1d202_ctl00_ctl04_ctl01_ctl00_ctl00_ctl04_ctl00_ctl00_TextField_spSave" />
            </span>
        </span>
    </td>
</tr>

【问题讨论】:

    标签: javascript jquery html


    【解决方案1】:

    您可以使用您所说的多行框来代替 div,但您可以在列表设置中更改列的字段属性,而不是更改代码,否则 SharePoint 可能会与您的列表字段断开连接'正在尝试更新。

    如果你必须使用 SharePoint 的控件,你也可以隐藏 div:style="display:none" 并使用您可以从 SP Designer 放在页面上的通用文本区域中的 jQuery 填充它 - 可以获得它的 .text().html().val() (不记得我的头顶是哪个),将其分配给 var textAreaText 然后使用

    $('id$=inplacerte').html(textAreaText);
    

    【讨论】:

      猜你喜欢
      • 2020-11-27
      • 1970-01-01
      • 1970-01-01
      • 2020-11-17
      • 1970-01-01
      • 2013-07-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多