Durandal widget needs a mobile view, can I use two views for one viewmodel?

44 views Asked by At

I have a Durandal widget, but now a mobile view is needed, this new view would use the same viewmodel. Would something like the following work:

if(mobile)
  widget.mapKind('myWidget','widgets/myWidget/mobileview','widgets/myWidget/viewmodel')
else //map with other view

and having a folder layout like:

widgets
|
|--myWidget
|--|--viewmodel
|--|--desktopview
|--|--mobileview

is this even good practice or should viewmodels only have one view?

If so is there another way to do this without having a different myWidgetMobile widget that duplicates a whole viewmodel?

I want to have the phone version as independent from the other view as possible so taking a mobile first approach with css is viewed as my plan Z.

0

There are 0 answers