Need Idea for confirm before delete using confirm |
There are several problems but the first to address is the use of a whole bunch of "deprecated" options. Deprecated is in quotes because that's what Sweet Alert calls them. To me that implies "You can use them by you shouldn't", but in reality is seems they don't work at all. That's my experience when obtaining the library via the CDN.
Code: <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script> Perhaps you are using an older version that was installed using npm? If so, you should upgrade that install. What I suggest here is based on using the script tag shown above. The next issue I see is how you define the function that responds to the dialog. Maybe you're using old syntax. The current syntax requires you attach a handler to the promise that swal() returns. Then there is the problem of using an anchor tag to go to the delete method. The way you have it structured that link will ALWAYS be followed even if you say "No" in the confirm dialog. It's also currently considered "bad practice" to use inline JavaScript as you by defining the "onClick" property of the anchor tag. Wow, I feel like I am really slamming you but that's not my intent. Sorry. Below is controller and view code to demonstrate something that works and addresses all the issues I observe. I mocked up values to send to the delete method and adjusted URIs to work with this test. To the best of my understanding this does what you seek to do. Controller Swal_test.php PHP Code: <?php The view file: swaltest_v.php PHP Code: <!DOCTYPE html> Hope this helps. |
Messages In This Thread |
Need Idea for confirm before delete using confirm - by googlemy - 02-04-2018, 03:48 AM
RE: Need Idea for confirm before delete using confirm - by wishmaster - 02-04-2018, 05:45 AM
RE: Need Idea for confirm before delete using confirm - by InsiteFX - 02-04-2018, 05:51 AM
RE: Need Idea for confirm before delete using confirm - by dave friend - 02-04-2018, 10:08 AM
|