Monday, March 28, 2016

How can I set the parent of an Element?

I am "injecting" HTML code into a contenteditable <div>. Since any content there could potentially be removed with e.g. BACKSPACE, I want to know when this elements are getting detached in order to remove the whole panel from the parent contenteditable div.

However, these events don't seem to work. I managed to get events like Event.ONKEYPRESS etc. but no Attach/DetachEvent.

I also tried a MutationObserver [1] - this is giving me at least the attach/detach event but the problem is that the elements which are coming in, at least those of which I am interested in, do not have a parent.

You can have a look at the code on my github repository if you want but please keep in mind this is just my own experimental stuff. Here [2] is how I "inject" the HTML code into the contenteditable at the caret position and here [3]
you can see the line where I have the problem of the parent being null.

Widget does have a setParent() method but I cannot override it.

[1] https://github.com/ArcBees/gwtquery-elastic-plugin/blob/master/elastic/src/main/java/com/arcbees/gquery/elastic/client/MutationObserver.java
[2] https://github.com/silentsnooc/contenteditable-textarea/blob/master/contenteditable-client/src/main/java/com/contenteditable/widget/MentionPanel.java#L203
[3] https://github.com/silentsnooc/contenteditable-textarea/blob/master/contenteditable-client/src/main/java/com/contenteditable/widget/MentionPanel.java#L60

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment