mardi 10 novembre 2015

Saving viewmodel object value

i am creating a date forward/backward funktion in MVC. I am very new at this and i want to ask how do i set a new value to an MVC object.

this is my code: i am sending a link with parameters to define a date and get data

    var getAbsenceList = function (location, userId, absenceDate, modifier) {
    $.get('ActivityWidget/MyActivityAbsenceListData/?location=' + location + '&userId=' + userId + '&modifier=' + modifier + '&absenceDate=' + absenceDate, function (response) {
        $('#absence-data').html(response.UserList);
        $('#absence-date-container').html(response.AbsenceDateData)
    });

my absenceDate is set i a partial view here:

@model MyActivityAbsenceViewModel
@string.Format("{0:dddd}", Model.AbsenceDate).UppercaseFirst() d. @string.Format("{0:d}", Model.AbsenceDate)
@Html.HiddenFor(m => m.AbsenceDate)

And this is my HTML code:

<table class="absence-widget-table">
    <tr>
        <td class="absence-widget-left">
            <i class="fa fa-chevron-left" title="Next" aria-describedby="ui-tooltip-1"></i>
        </td>
        <td class="absence-widget-center" id="absence-date-container">
            @Html.Partial(MVC.ActivityWidget.Views.Partials.MyActivityAbsenceDateChanger, Model)
        </td>
        <td class="absence-widget-right">
            <i class="fa fa-chevron-right" title="Previous"></i>
        </td>
    </tr>
</table>

when i press the next or previous button absenceDate is always todays date. It doesnt change the value when one of the buttons are presssed.

cna anyone help?

thanks.

Aucun commentaire:

Enregistrer un commentaire