I am trying to use unobtrusive ajax to update my partial views. Unfortunately I ran in to a problem when I was about to install the package, since Bower is not working (?) or recommended anymore according to https://docs.microsoft.com/en-us/aspnet/core/client-side/bower?view=aspnetcore-2.1. Instead they recommend us to use Libman.
I followed the steps from https://www.c-sharpcorner.com/article/unobtrusive-ajax-and-jquery-for-partial-updates-in-asp-net-mvc/.
So I have installed the nuget Microsoft.jQuery.Unobtrusive.Ajax-package, but how do I reference the ajax-package with libman?
I looked at this How to reference Microsoft.JQuery.Unobtrusive.Ajax within my ASP.NET Core MVC project answer but it only shows how to use Bower.
The jQuery Unobtrusive Ajax library complements jQuery Ajax methods by adding support for specifying options for HTML replacement via Ajax calls as HTML5 data-* elements. This project is part of ASP.NET Core. You can find samples, documentation and getting started instructions for ASP.NET Core at the Home repo.
The idea behind Unobtrusive AJAX is that AJAX behaviour is attached to form and anchor elements via HTML5 data-* attributes, instead of binding click event handlers in script blocks. In old MVC, these attributes can be generated from Html helpers: Ajax. BeginForm and Ajax. ActionLink and then setting some AjaxOptions .
In this article, you will learn about Client-Side Package Management with Library Manager in Visual Studio. Library Manager is a lightweight, client-side library acquisition tool. Developers can retrieve libraries like jQuery, bootstrap, Vue. js, and others from various supported CDNs or even the file system.
I struggled with LibMan at first too. I found this guide that points out there's a GUI portion of LibMan. Using the UI portion of LibMan under the "project right click menu -> Add -> Client-Side Library" helped me figure out better ways to define which files I want and change the provider easier.
I ended up having most of my files come from cdnjs, but I set up jquery-ajax-unobtrusive to come from unpkg like so:
{
"provider": "unpkg",
"library": "[email protected]",
"destination": "wwwroot/lib/jquery-ajax-unobtrusive/"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With