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

Checked and Clicked Binding problem

11 Answers 278 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
sitefinitysteve asked on 11 Feb 2013, 05:44 AM
Reference this demo: http://demos.kendoui.com/web/mvvm/elements.html

Okay so when a checkbox is checked, the array gets updated right...

Then when the array changes, I need to fire off a callback to a service, AND update the checkbox by adding\removing a class.

What seems to happen is that the click event fires first, so the callback doesn't send back the proper values from the array (like I'm always one selected value behind).

?

Steve

11 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 12 Feb 2013, 09:23 AM
Hello Steve,

The array should be updated immediately when a checkbox is selected and the UI is updated after that. Here is a JSBin example which shows that the array is updated accordingly to the selection which was made.

http://jsbin.com/igirur/2/edit

Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 12 Feb 2013, 01:08 PM
Try this one instead: http://jsbin.com/igirur/4/edit

0
Petur Subev
Telerik team
answered on 14 Feb 2013, 12:23 PM
Hello Steve,

I am not sure I understand the question, can you please explain in more details what exactly is the issue with the example you shared?


Kind Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 14 Feb 2013, 01:16 PM
OH!...I assume you tried it in chrome and it's fine

..try Firefox
0
Petur Subev
Telerik team
answered on 18 Feb 2013, 10:14 AM
Hello Steve,

The order of the events being triggered is different.

Same is happening here try with different browsers again:

http://jsbin.com/anafev/2/edit

Kind Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 19 Feb 2013, 07:16 PM
I know, I'm not exactly sure what you're telling me here...I'm reporting the one reporting the events are firing at different times on different browsers?

0
Petur Subev
Telerik team
answered on 21 Feb 2013, 12:59 PM
Hello Steve,

There is not any kendo code in this example and the events are fired in different order. And since Kendo depends on the order in which the events are fired, Kendo will behave the same way as the events are fired.

There is nothing we can do to change the order of the events in the different browsers.

All the best,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 21 Feb 2013, 01:25 PM
There's no way for kendo to account for this...not even file something with mozilla...orr....anything, I'm just screwed here?
0
Petur Subev
Telerik team
answered on 25 Feb 2013, 07:40 AM
Hello again Steve,

As I already replied in my previous post I am sorry but there is nothing we can do.

Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Keith
Top achievements
Rank 2
Iron
Veteran
answered on 03 May 2019, 02:36 PM

Is this still the case?  If so wow!  So in Chrome, the click event's reading of the bound vm value is the original value, then after the click finishes the binding is updated to the new value.  Yet in IE, the binding update is made prior to the click event.  Fascinating!  

What is the best way to read the desired value during the click event, something of the parameter, I'll call 'e'?

0
Veselin Tsvetanov
Telerik team
answered on 07 May 2019, 10:56 AM
Hello Keith,

As Petur has explained previously, the Kendo implementation depends on the browser event sequence. If the different browsers follow different sequence for those events (Chrome and Firefox vs IE and Edge), there is nothing much we can do.

As per the scenario that has been previously discussed, an ugly (but working) workaround would be to timeout the execution of the logic in the click handler. This way, the value will be changed accordingly independent from the event sequence:
filterChanged: function (e) {
  setTimeout(function() {
    clickFilter.html($restViewModel.displayselectedFilters());
  });
}

Here you will find a sample Dojo implementing the above.

Regards,
Veselin Tsvetanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
MVVM
Asked by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Answers by
Petur Subev
Telerik team
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Keith
Top achievements
Rank 2
Iron
Veteran
Veselin Tsvetanov
Telerik team
Share this question
or