gpt4 book ai didi

javascript - 未触发 Angular contenteditable 更改事件

转载 作者:行者123 更新时间:2023-11-30 15:56:31 25 4
gpt4 key购买 nike

我在对 execCommand 上的 Controller 范围应用直接更改时遇到问题。

在找到的 contenteditable 指令中未触发 change 事件 here我必须模糊 div 才能应用更改。这是一个错误还是还有其他事情要做?

这是我的 jsfiddle用于测试。

=== 编辑 ===

大胆的 execCommand 正在 dom 上工作,但它不会直接更新 Controller 范围,除非事件被触发,如 keyup on the field 或 blur。

Real time field is not update

最佳答案

change事件不会在对 DOM 元素的值进行所有更改时触发。解决方案是使用 input事件。

  element.on('input', function() {
scope.$evalAsync(read);
});

change

Unlike the input event, the change event is not necessarily fired for each change to an element's value.

-- Mozilla Developer Network -- Events -- Change


input

The DOM input event is fired synchronously when the value of an <input> or <textarea> element is changed. Additionally, it fires on contenteditable editors when its contents are changed. In this case, the event target is the editing host element. If there are two or more elements which have contenteditable as true, "editing host" is the nearest ancestor element whose parent isn't editable.

-- Mozilla Developer Network -- Events -- Input

关于javascript - 未触发 Angular contenteditable 更改事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38444183/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com