I can't get my checked values to pass to my viewmodel that is being accepted by my controller action method. I'm using the prettycheckable jquery plugin.
$("#HostCreateEvent").prettyCheckable();
<input type="checkbox" name="HostCreateEvent" id="HostCreateEvent" data-label="Event Created" value="@Model.HostCreateEvent" @(Model.HostCreateEvent == true ? "checked" : "") />
Here is my controller and viewmodel
[HttpPost]
public ActionResult Notification(UserNotificationViewModel viewModel)
{
try
{
ViewBag.Title = "Account";
ViewBag.MenuItem = "account";
ViewBag.UserMenuItem = "notification";
_yogaProfileService.SaveNotificationInfo(User.Identity.GetUserId(), viewModel);
TempData["success"] = true;
TempData["message"] = "Successfully updated notifications";
return View(viewModel);
}
catch (Exception ex)
{
_errorService.LogError(ex, Request);
ModelState.AddModelError("", "Something went wrong updating your notification settings!");
return View(viewModel);
}
}
and my viewmodel
public class UserNotificationViewModel
{
public bool HostCreateEvent { get; set; }
}