I have set up my ViewModel for the View:
public class DashboardViewModel
{
public List<UserTask> UserTasks {get; set;}
public List<WorkItem> WorkItems {get; set;}
}
In the View, I am looping through the WorkItems as follows:
@foreach (var item in Model.WorkItems)
{
@item.Name
@item.HoursLogged
<button value="@item">UPDATE</button>
}
When the button is clicked, a jQuery function launches a modal.
To display all information about the item in the modal, I need to pass the item.
Here's the javascript function that handles this:
$(buttonEl).click(function () {
//code to open modal
var item = this.value;
});
The value passed in "this.value" is not an object but a string with the namespace of the WorkItem.
I also attempted using inline onclick function:
<button onclick="openModal('@item')">UPDATE</button>
Unfortunately, I'm facing the same issue. Any suggestions?