Greg Gum Greg Gum - 2 months ago 5
Javascript Question

What does 'data()' do in '$("#myWidget").data(`ejTE`)'

This works:

var editor = $("#htmlEditor").data('ejRTE');


The question is what does
.data('ejRTE')
do?

It retrieves the widget which is part of this html:

<textarea id="htmlEditor" value.bind="entity.content"
ej-rte="e-width:100%"
ref="textArea"
style="height: 220px"></textarea>


How do I retrieve it without jQuery.

KAD KAD
Answer

jQuery.data() Store arbitrary data associated with the specified element and/or return the value that was set.

So basically the widget stores some data in the element htmlEditor indexed ejRTE, I bet it is a custom object used by this tool.

var editor = $("#htmlEditor").data('ejRTE');

then editor will hold the object stored by the widget for this element

Comments