kossa/laradminator

How can I enable jquery/javascript libraries?

Closed this issue · 3 comments

Hello, I have just installed your code. Your installation instructions are very clear but I'm new to the whole laravel mix thing and cannot figure out how to enable the various javascript libraries. I successfully installed the node_modules using yarn, enable npm watch and then I added the following code to the end of resources\views\admin\index.blade.php to test jquery using sweetalert2:
@section('js') <script> $(function(){ Swal.fire('hello world'); }); </script> @endsection
I expected a simple alert popup when reloading, but nothing happens. In resources\js\bootstrap.js there is already a line at the bottom with import './sweetalert2'; so I assume that the library is being loaded. What am I missing?

kossa commented

Alright, if you try to remove a user you'll see a sweet popup confirmation,

jQuery is already installed.

You can import and use jQuery plugin like select2 in this example : https://github.com/kossa/laradminator/blob/master/resources/js/select2/index.js
Or Sweetalert : https://github.com/kossa/laradminator/blob/master/resources/js/sweetalert2/index.js

Note that all js plugins are located in resources/js/

Note: Currently for sweetalert I'm using https://github.com/realrashid/sweet-alert

Thank you for the reply, however I am not able to get it to work. I do not get any sweetalert confirmation when trying to delete a user. It simply deletes the user and gives me a notification that the user has been deleted. The "npm run watch" was initiated at the server. The various chart examples seems to work, so I'm not sure what is different.

I have attached some screenshots that show what I am working with. First is the resources/js/sweetalert2/index.js file that has the code you referenced in your reply.

Second is my attempt to use sweetalert2. It shows the jquery code I have added, at the bottom of views/admin/dashboard/index.blade.php. It thought it would just display the sweet alert message when the page loads, but it does not.

Finally, I have included a screenshot showing where I have added the import command to resources/js/index.js in an attempt to get it to work.

Am I doing something wrong? Did I overlook something?

Screen Shot 2019-08-25 at 5 44 39 PM
Screen Shot 2019-08-25 at 5 45 26 PM
Screen Shot 2019-08-25 at 5 59 31 PM

kossa commented

I think problem with your NPM

Can you check : http://laradminator.bel4.com/admin/users

Username: test@example.com

Password: 123456

And delete a user