den
den

Reputation: 709

Multi datepicker binding

I have got a multi datepicker class

$(".multiDateInput").multiDatesPicker({
    changeMonth: true,
    changeYear: true,
    dateFormat: 'dd/mm/yy',
    gotoCurrent: true
});

In my controller I get a list of dates

var temp = query.ToList().Select(r => r.Date.ToShortDateString());

and bind them to my model

model.BankHolidays = String.Join(",", temp);

In my view I have

@Html.TextBoxFor(r => r.BankHolidays, new { @class = "multiDateInput" })  

when the view is loaded the textbox is empty. If I remove the class:

eg @Html.TextBoxFor(r => r.BankHolidays) it works fine

The source looks right

<input class="multiDateInput" id="BankHolidays" name="BankHolidays" type="text" value="01/01/2013,02/01/2013" />

Upvotes: 1

Views: 429

Answers (1)

liri2006
liri2006

Reputation: 591

Due to documentation you have to use 'addDates' option to set preselected dates:

var date = new Date();
$('#pre-select-dates').multiDatesPicker({
    addDates: [date.setDate(14), date.setDate(19)]
});

Upvotes: 1

Related Questions