2

I'm trying to create a custom widget in GWT that creates a div with contenteditable=true inside of it. The problem is that when I create this div and I initialize this widget, the div does not have the contenteditable property.

my code:

public MyWidget(){ FlowPanel panel = new FlowPanel(); initWidget(panel); HTML div = new HTML("<div id=\"my-div\" contenteditable=true></div>"); div.setText("hello there"); div.addHandler(new MyWidgetKeyDownHandler(), KeyDownEvent.getType()); mDiv = div; panel.add(div); } 

But when I run the code and I inspect the source, I see this:

<div> <div class="gwt-HTML">hello there</div> </div> 

So it looks like it's missing the contenteditable tag as well as the id. What am I doing wrong here? How can I create this contenteditable div widget?

1 Answer 1

3
div.getElement().setAttribute('contenteditable', 'true'); 

I would work around your requirement for a specific id. You can set one with ensureDebugId but you might find it simpler to do without it.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.