This is a migrated thread and some comments may be shown as answers.

How To Change DOM element from JS and how to get changed elements

1 Answer 84 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
goex
Top achievements
Rank 1
goex asked on 14 Apr 2014, 10:06 PM
Hello,

I am trying to understan how syncronization in data binding and afterwards the tracking of changed values works. Therefore I have 2 connected questions

Question 1 :  In kendo ui documentation it says that "When the end-user changes the value of the DOM element (or widget) the bound View-Model value is updated. If the View-Model value is updated from code the value of the bound DOM element (or widget) is updated visually."I couldn't find how the second section (in bold) works.

I tried to writedevicenoValue = "444444";

to check if the DOM element is changing but it didn't work. How can I change it from the javascript side (ofcourse without the standart jquery option)

html code is :

<li>
<label>Device No
<input type="text" value="" id="device_no" data-value-update="keyup" data-bind="value: devicenoValue"/>
</label>
</li>

JS code is :

var settings = kendo.observable({

devicenoValue: "444444"
});

kendo.bind($("#device_no"), settings);



Question 2 : I need to know which element was changed in the DOM. How can I find this? I tried data-value-update="keyup" but couldn't findout how to use it for this purpose




1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 15 Apr 2014, 11:12 AM
Hi,

It seems your first question was answered in stackoverflow. You can use the change event of the DOM element to see what changed:

<input data-bind="events: {change: onChange}">

var viewModel = kendo.observable({
   onChange: function(e) {
       var target = e.target; // the DOM element which triggered the event (changed)
   }
});

Regards,
Atanas Korchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
General Discussions
Asked by
goex
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or