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

Switch widget and MVVM

9 Answers 512 Views
Switch (Mobile)
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 06 Sep 2012, 10:54 AM
Hi! Could you provide me small example to bind model member (boolean) to Switch widget state.
I would expect something like
<input data-role="switch" data-bind="checked:checked"/>

But it looks terrible and does not work. Another question: why after binding my Tabstrip looks "doubled"
http://jsfiddle.net/GewUa/5/ 

9 Answers, 1 is accepted

Sort by
0
Accepted
Georgi Krustev
Telerik team
answered on 10 Sep 2012, 04:06 PM
Hello Alex,

 
The switch widget is initialized twice, which is not supported. I will suggest you use the data-model attribute.
Here is the updated jsFiddle demo.

Regards,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Eric
Top achievements
Rank 1
answered on 09 Mar 2014, 07:50 PM
What if you have a view with a form and because of the requirements cannot use the data-model attribute to bind the information to the view, but instead bind it as Alex shows it during data-before-show or data-show? How can you bind to a switch correctly declaratively? How can you make it so that the switch does not get initialized twice?

Please, advise!
0
Georgi Krustev
Telerik team
answered on 11 Mar 2014, 12:10 PM
Hi,

You can use View's init event to bind the view's content. Check the updated jsFiddle demo.

Regards,
Georgi Krustev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Amitesh
Top achievements
Rank 2
answered on 02 Apr 2014, 01:53 AM
Hi Georgi,

The binding for the switch on the demo actually is not working.

Regards,

Ikhwan
0
Georgi Krustev
Telerik team
answered on 04 Apr 2014, 04:08 PM
Hello,

Indeed, the binding does not work, because I missed to specify a namespace. Here is the correctly defined kendo.bind method call. Please note, that the preferred way to bind a Mobile View is using the data-model attribute.

Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Mike
Top achievements
Rank 1
answered on 19 Jul 2016, 03:31 PM

Your link to "the data-model attribute" is broken.

Is it supposed to be linked here? http://docs.telerik.com/kendo-ui/api/javascript/data/model

If so, can we see an example of the "correct" way to bind the switch control?

0
Georgi Krustev
Telerik team
answered on 20 Jul 2016, 08:23 AM
Hello Mike,

The "data-model" link was supposed to point the readers to the correct way to bind Mobile View:

http://docs.telerik.com/kendo-ui/api/javascript/mobile/ui/view#configuration-model

As to how a slider can be bound to MVVM model, then I would suggest you examine our online demo and the corresponding MVVM value binding documentation:

http://docs.telerik.com/kendo-ui/framework/mvvm/bindings/value
http://demos.telerik.com/kendo-ui/slider/mvvm

Regards,
Georgi Krustev
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
0
Running
Top achievements
Rank 1
answered on 27 Jun 2018, 10:38 PM
This post is about the kendo switch. Why is the Admin posting links to the slider widget? Is there any complete documentation on how to use the SWITCH widget with MVVM?     
0
Konstantin Dikov
Telerik team
answered on 02 Jul 2018, 12:02 PM
Hello,

For your convenience, following is a dojo example with MVVM initialization of the MobileSwitch:
Hope this helps.


Regards,
Konstantin Dikov
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Switch (Mobile)
Asked by
Alex
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Eric
Top achievements
Rank 1
Amitesh
Top achievements
Rank 2
Mike
Top achievements
Rank 1
Running
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or