【问题标题】:delete & back space not working in radeditor删除和退格在 radeditor 中不起作用
【发布时间】:2015-01-03 23:37:41
【问题描述】:

我在我的项目中使用 radeditor。 我创建了一些我在文本区域中插入的自定义标签 Bellow 是带有文本的这个标签的演示 html 代码

this is demo<var is-end="false" conditionid="439726" conditionfield="FELT001" conditionlabel="new co" title="Start of condition: new co" style="display: inline-block; width: 16px; height: 16px; margin-right: 3px; background-image: url('http://localhost/dialogportal.com/images/icons/condition-begin.gif'); background-repeat: no-repeat;" contenteditable="false"></var> text <var is-end="false" conditionid="439726" conditionfield="FELT001" conditionlabel="new co" title="Start of condition: new co" style="display: inline-block; width: 16px; height: 16px; margin-right: 3px; background-image: url('http://localhost/dialogportal.com/images/icons/condition-begin.gif'); background-repeat: no-repeat;" contenteditable="false"></var>again this will have conditions<var is-end="true" conditionid="439726" title="End of condition: new co" style="display: inline-block; width: 16px; height: 16px; margin-left: 3px; background-image: url('http://localhost/dialogportal.com/images/icons/condition-end.gif'); background-repeat: no-repeat;" contenteditable="false"></var><var is-end="true" conditionid="439726" title="End of condition: new co" style="display: inline-block; width: 16px; height: 16px; margin-left: 3px; background-image: url('http://localhost/dialogportal.com/images/icons/condition-end.gif'); background-repeat: no-repeat;" contenteditable="false"></var>&nbsp;which we have to test

看起来像这样

在这里我们可以同时看到两个 VAR 标签。他们在 chrome 和 safari 中出现问题。 也不使用左右箭头,我不能通过这个 var 标签,也不能使用退格和删除。

这个问题只出现在 chrome 和 safari 中,而不出现在 firefox 和 IE 中。

【问题讨论】:

    标签: javascript asp.net telerik radeditor


    【解决方案1】:

    编辑器在其内容区域中附加了许多事件 - 其中之一当然是 onkeydown。 由于某些浏览器的怪癖,当按下 BACK 或 DELETE 时,编辑器需要执行一些代码。

    当您在 OnClientLoad 中注册自己的处理程序时,您的代码将在编辑器自己的事件处理程序之后执行。

    不幸的是,没有“标准”方法来覆盖此行为。然而——下面的代码是一个相当简单的方法,应该可以解决这个问题——你需要做的就是在你的编辑器声明之后添加这个脚本。 本质上,如您所见,代码覆盖了编辑器的私有 _onKeyDown 方法,并允许您在那里执行自己的代码。

    <script>            
               Telerik.Web.UI.RadEditor.prototype.old_onKeyDown = Telerik.Web.UI.RadEditor.prototype._onKeyDown; 
               Telerik.Web.UI.RadEditor.prototype._onKeyDown = function (e) 
               { 
                 //Write your own here 
                 if (e.keyCode == 8) //BACK was pressed 
                 {            
                    //if you do not want the editor to execute its own code cancel event 
                    return $telerik.cancelRawEvent(e);               
                 }            
                 //Call original code 
                 this.old_onKeyDown(e); 
               } 
               </script> 
    

    请注意,这有点小技巧。虽然我们不希望在可预见的将来更改此方法的名称,但它仍然不是公共方法,因此无法保证。

    【讨论】:

    • 这只会取消 Back 事件。那么如何删除带有空格的标签或删除?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-02-12
    • 1970-01-01
    • 2012-02-05
    • 2015-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多