HTML5,draggable and contentEditable not working together

后端 未结 4 2106
-上瘾入骨i
-上瘾入骨i 2020-12-15 06:12

When a draggable attribute is enabled on a parent element(

  • ) I cant make contenteditable work on its child element (<
  • 4条回答
    •  無奈伤痛
      2020-12-15 06:48

      Using html5sortable and newer JQuery events (delegate is deprecated, answer 3 years after initial question), bug still affects Chrome 37. Contenteditable spans and html5sortable seem to play nice in other browsers. I know this is only partially relevant, just keeping documentation on changes I've noticed.

      $(document).on('focus', 'li span[contenteditable]', function() {
          $(this).parent().parent().sortable('destroy'); // removes sortable from the whole parent UL
      });
      
      $(document).on('blur', 'li span[contenteditable]', function() {
          $(this).parent().parent().sortable({ connectWith: '.sortable' }); // re-adds sortable to the parent UL
      });
      

    提交回复
    热议问题