[ASP.NET Core] Help using js library in my view?
I am trying to use paginationjs library: https://github.com/superRaytin/paginationjs in my home index view in a script tag. so I went to the wwwroot/lib, i right clicked and searched for paginationjs and installed it. and then i saw the paginationjs folder appear in the lib folder. so then I made a script tag and put it in my view. and then in the shared _layout.cshtml, I have the jsquery script tag
i also made an empty div for the pagination container and then i made the below script:
however, whenever I run it in the browser, i see in the console:
how can i fix this? it doesnt recognize the library at all even th ough its installed
10 Replies
Where did you put the library import, and where did you put the inline script tag?
The library has to be loaded before your script
i was working on it before you cam e but what i did was i went and i copied all of the scripts from paginationjs.com and i have it in my clipboard, then i made a new file in /wwwroot/js called
pagination.js
and then i used the script to reference it, so i have the script loading and then the script to populate the grid afterwards
and then in shared _Layout.cshtml, I have this in the head
but for some reaosn when i launch the app and look in the browser, i see this
i changed it to this and now it is able to find the script
but it still says $(...) is not a function
which doesnt make sense cause jquery works fine i tested it
so i dont understand
Try to wrap it in a
document.ready
function? https://learn.jquery.com/using-jquery-core/document-ready/ok
one sec
still doesnt work unfortunately