Text area gaining multiple inner sections

1 Answer 362 Views
TextArea
Kevin
Top achievements
Rank 2
Iron
Iron
Iron
Kevin asked on 10 Jun 2022, 03:45 PM | edited on 10 Jun 2022, 03:45 PM

I have a grid with an edit button which opens a modal window

Inside that modal window I have a text area

Each time I set the value, it indents

$("#mytextarea").kendoTextArea().data('kendoTextArea').value("A new comment here");

It starts to do this which each successive setting of the value.

<span class="k-input k-textarea k-input-solid k-input-md k-rounded-md" style="width: 100%;">

<span class="k-input k-textarea !k-overflow-y-auto k-input-inner k-input-solid k-input-md k-rounded-md" style="width: 100%; resize: none;">

<span class="k-input k-textarea !k-overflow-y-auto k-input-inner k-input-solid k-input-md k-rounded-md" style="width: 100%; resize: none;">

<span class="k-input k-textarea !k-overflow-y-auto k-input-inner k-input-solid k-input-md k-rounded-md" style="width: 100%; resize: none;">

<textarea id="setup-deliverymethod-dialog-comments-textarea" style="width: 100%; resize: none;" data-role="textarea" aria-disabled="false" rows="1" placeholder="Comments" class="!k-overflow-y-auto k-input-inner" autocomplete="off"></textarea>

</span>

</span>

</span>

</span>

Am I setting the textarea value incorrectly?

 

1 Answer, 1 is accepted

Sort by
0
Georgi Denchev
Telerik team
answered on 15 Jun 2022, 10:16 AM

Hello, Kevin,

Thank you for the provided details.

The problem most likely occurs because the TextArea is being initialized over and over again, whenever you click the button.

The following part of the code should be executed only the first time you initialize the window(I'm assuming you're not destroying it):

$("#mytextarea").kendoTextArea()

After that, the above piece of code should not be called, since the textarea is already created. You can simply get a reference to the widget and update its value:

var textarea = $("#mytextarea").data("kendoTextArea");

if(!textarea) {
 textarea = $("#mytextarea").kendoTextArea();
}

textarea.value("My new value");

Let me know if you have any questions.

Best Regards,
Georgi Denchev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
TextArea
Asked by
Kevin
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Georgi Denchev
Telerik team
Share this question
or