2016-12-13 16 views
0

私はフォームとckeditorでモーダルを使用し、リンク入力が機能しないプロジェクトがあります。CKEditorリンク入力がモーダルで動作しません

http://jsfiddle.net/8t882a2s/3/

そして、この例のコード:

ここでは、この問題を再現フィドルです。

HTML:

 <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> 
      <div class="modal-dialog"> 
       <div class="modal-content"> 
        <div class="modal-header"> 
         <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button> 
         <h4 class="modal-title" contenteditable="true" id="myModalLabel">Modal title</h4> 
        </div> 
        <div id="bodyModal" contenteditable="true" class="modal-body"> 
         ... 
        </div> 
        <div class="modal-footer"> 
         <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> 
         <button type="button" class="btn btn-primary">Save changes</button> 
        </div> 
       </div> 
      </div> 
     </div> 

<button type="button" class="btn btn-default navbar-btn margin-right-button-nav" data-toggle="modal" data-target="#myModal"><span class="glyphicon glyphicon-new-window"></span> Edit Modal</button> 

JS:

CKEDITOR.disableAutoInline = true; 

$(document).ready(function() { 
    $('#myModal').on('shown.bs.modal', function() { 
     CKEDITOR.inline('myModalLabel'); 
     CKEDITOR.inline('bodyModal'); 
    })  
}); 

これはまさに私のコードではなく、バグが同じです。モーダルをクリックしてリンクを追加しようとすると、入力フィールドにURLを書き込むことができません。その後、

$.fn.modal.Constructor.prototype._enforceFocus = function() { 
       var $modalElement = this.$element; 
       $(document).on('focusin.modal',function(e) { 
        if ($modalElement[0] !== e.target 
         && !$modalElement.has(e.target).length 
         && $(e.target).parentsUntil('*[role="dialog"]').length === 0) { 
         $modalElement.focus(); 
        } 
       }); 
      }; 

あなたは、ブートストラップ3上で実行されている場合は、:

感謝:)インターネットのまわりの回答の

答えて

1

多くは、修正のための複数の方法を提案し、 これは、ブートストラップ4プロジェクトのために、私のために働いたがインサイド$.fn.modal.Constructor.prototype.enforceFocusを上書きしてください。

関連する問題