简体   繁体   English

无法使标题可编辑

[英]Can't make header editable

I have a working Drag and Drop sample code.我有一个有效的拖放示例代码。 But now I want to make header editable.但现在我想让标题可编辑。 It doesn't let me to make it contenteditable="true" on left click of mouse (however on right click it does.).它不允许我在鼠标左键单击时使其contenteditable="true" (但是右键单击它确实如此。)。 This error occurs because this edit-able-content is under the header.发生此错误是因为此可编辑内容位于标题下。 So on click it lets user to move the content not edit.所以点击它可以让用户移动内容而不是编辑。 I can not change the HTML style, means I cant put this edit-able-content outside the header div.我无法更改 HTML 样式,这意味着我无法将此可编辑内容放在标题 div 之外。

Whole code is available in JSfille完整代码在 JSfille 中可用

Demo演示

HTML HTML

<div class="portlet-header">
<span class="red uppercase-text headerEditable" contenteditable="true">Error is here
</span>
</div>

JqueryUI code jQueryUI 代码

$(function () {
          $(".column").sortable({
              connectWith: ".column",
              handle: ".portlet-header",
              cancel: ".portlet-toggle",
              placeholder: "portlet-placeholder ui-corner-all"
          });

          $(".portlet")
              .addClass("ui-widget ui-widget-content ui-helper-clearfix ui-corner-all")
              .find(".portlet-header")
                  .addClass("

    ui-widget-header ui-corner-all")
                  /* .prepend( "<span class='ui-icon ui-icon-minusthick portlet-toggle'></span>"); */

              $(".portlet-toggle").click(function () {
                  var icon = $(this);
                  icon.toggleClass("ui-icon-minusthick ui-icon-plusthick");
                  icon.closest(".portlet").find(".portlet-content").toggle();
              });

You have to cancel the sortable feature on the contenteditable too using cancel option.您也必须使用cancel选项cancel contenteditable 上的可排序功能。

Code:代码:

  $(".column").sortable({
      connectWith: ".column",
      handle: ".portlet-header",
      cancel: ".portlet-toggle, .headerEditable",
      placeholder: "portlet-placeholder ui-corner-all"
  });

Demo: http://jsfiddle.net/IrvinDominin/pf83aLqt/演示: http : //jsfiddle.net/IrvinDominin/pf83aLqt/

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

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