I make product my favourite with Javascript yes no window. When click yes button, product gets my favourite and refresh background page. I have MakeMyFavorite action in the controller, but it return same result every call.
public ActionResult MakeMyFavorite( int id )
{
....
return RedirectToAction( "Details", "Product", product );
}
and Javascript:
<script language="JavaScript" type="text/javascript">
function confirmFavorite() {
if (confirm("Are you sure make favorite?")) {
document.location.reload(true);
return true;
} else {
return false;
}
}
</script>
and link:
<a href="@Html.Action ( "MakeMyFavorite", "Product", new { id = item.ID } )"
onclick = "return confirmFavorite()"> Make Favorite </a>
I use Make Favorite link in different places in the site (Details, Index and other views). When click link, product is favourite, page refresh, but always opens Details view.
I changed ActionResult with void in the controller, but never open, because, there is not return view.
How should I do, in different pages of site, when I click Make Favorite link, product is favourite, but background page not change? To stay current view. (Sorry for bad English)
You can do this
Make a JsonResult Action
Like
Make your anchor tag like
and your jquery for handling this