【问题标题】:Backspace not removing table in wysiwg editor in Firefox退格键未在 Firefox 的所见即所得编辑器中删除表格
【发布时间】:2015-01-03 22:04:52
【问题描述】:

我已经创建了一个按钮来在所见即所得的引导编辑器中插入表格。该代码在谷歌浏览器中运行良好。我可以使用退格键添加表格、插入内容和删除表格。

但在 Firefox 中,我既不能使用退格键删除表格,也不能在表格外点击。

这是我的代码:

<div class="row">
    <div class="btn-toolbar" data-role="editor-toolbar" data-target="#editor">
        <div class="btn-group">
            <button class="btn btn-primary" title="" id="tblBtn" data-original-title="Insert table (or just drag &amp; drop)"><i class="glyphicon glyphicon-picture"></i>     </button>
        </div>
    </div>
    <div id="editor" class="well col-md-9">

    </div>
</div>


<div id="tblModal" class="modal fade">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title">Insert Table</h4>
                </div>
                <div class="modal-body">
                    <div class="form-group">
                        @Html.Label("Row : ", new { @class = "control-label col-md-2" })
                        <div class="col-md-10">
                            <input type="text" id="row" name="width" class="form-control" />
                        </div>
                    </div>
                    <br />
                    <br />
                    <div class="form-group">
                        @Html.Label("Colum : ", new { @class = "control-label col-md-2" })
                        <div class="col-md-10">
                            <input type="text" id="col" name="height" class="form-control" />
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" id="tblOk" class="btn btn-default">Ok</button>
                    <button type="button" class="btn btn-primary" data-dismiss="modal">Cancel</button>
                </div>
            </div>
        </div>
    </div>
<script type="text/javascript">
    $("#tblBtn").click(function () {
        $("#row").val("");
        $("#col").val("");
        $("#tblModal").modal('show');
    });

    $("#tblOk").click(function () {
        var row = parseInt($("#row").val());
        var col = parseInt($("#col").val());
        $("#editor").append("<table id='customTable' border='1'></table>");
        $("<tbody/>").append(function () {
            var $container = $('#customTable');
            for (var i = 0; i < row; i++)
            {
                $container.append("<tr id='newTR'></tr>");
                    var $tr = $("#newTR");
                    for (var j = 0; j < col; j++)
                    {
                        $tr.append($("<td/>").html(" ").css({ "width": "50px", "height": "30px" }));
                    }
                    $("#newTR").removeAttr("id");

            };
            return $container.html();
        });
        $('#customTable').removeAttr("id");
        $("#tblModal").modal('hide');
    });
</script>

谁能帮帮我?

【问题讨论】:

    标签: jquery twitter-bootstrap firefox cross-browser


    【解决方案1】:

    我已经通过在&lt;table&gt; 标记的末尾和开头添加&lt;br /&gt; 解决了这个问题,如下所示:

    $("#editor").append("<br /><table id='customTable' border='1'></table><br />");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多