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

Calendar widget binding isn't funky

2 Answers 46 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 23 May 2012, 02:46 PM
It's a list of items, the calendar is bound to a date value on the "SelectedItem"

So when selected item changes I want to show the value in the calendar.

However what's happening is that the calendar just keeps animating (rather choppy) back to may 2012 over and over with no selected dates.

This is the date value I'm binding to "2013-04-01T00:00:00"

Here's the markup
<li>Starts: <span data-role="calendar" data-bind="value: selectedBlock.data.StartDate"></span></li>

ideally i'd like no animation, and just want to visualize the dates

2 Answers, 1 is accepted

Sort by
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 23 May 2012, 02:50 PM
...oh wait, is it becasue the "date" is a string and not a JS date?

**Edit**
Yeah seems that way...well hmm...I'm not sure how to handle this...
All the data is coming down as json, how do I go about converting and binding to the pure date over the string?
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 23 May 2012, 05:16 PM
So I can see I can change it with a template
#: new Date(get("StartDate")).format("MMM dd, yyyy") #

...but that doesn't seem to be bound to the data in that when I change StartDate this template gets evaluated again

Just for the heck of it I tried this too :)
<span class="blockDate" data-bind="template : '#: new Date(get("StartDate")).format("MMM dd, yyyy") #'"></span>
Tags
MVVM
Asked by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Answers by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Share this question
or