0

I am using an onclick on a delete call

<input type='button' value='Delete' class='btn btn-danger btn-sm' 
id='btn_Delete6' profile-id='#= ProfileID#'>

and this is the script that it runs

$(document).ready(function () {
        $('body').on('click', 'td input', function () {
            swal({
                title: "Are you sure?",
                text: "You will not be able to recover this imaginary file!",
                type: "warning",
                showCancelButton: true,
                confirmButtonClass: 'btn-danger',
                confirmButtonText: 'Yes, delete it!',
                cancelButtonText: "No, cancel plx!",
                closeOnConfirm: false,
                closeOnCancel: false
            },
            function (isConfirm) {
                if (isConfirm) {
                    swal("Deleted!", "Your imaginary file has been deleted!", "success");
                } else {
                    swal("Cancelled", "Your imaginary file is safe :)", "error");
                }
            });
        });

    })

The issue is that I don't know how to get the url to run during the isConfirm function. I pass the profileID of the row into the url with profile-id. How can I call the /OBProfile/Delete/"profileid" that I need? This is done using SweetAlert

TheDizzle
  • 1,534
  • 5
  • 33
  • 76

2 Answers2

1

What do you mean by "Call an url", you mean going to it?

That would be done like this:

window.location.href = '/OBProfile/Delete/whatevertheprofileisis';

UPDATE AFTER COMMENT

I think this will come in handy. AngularJS. How to call controller function from outside of controller component

Community
  • 1
  • 1
Jean-Paul
  • 380
  • 2
  • 9
  • 26
  • I need to run the specific url `/OBProfile/Delete/whatevertheprofileisis` so it hits the controller and post back properly. – TheDizzle Jul 20 '15 at 15:09
  • @TheDizzle - Thi is the right answer, just swap `http://www.google.com` for `/OBProfile/Delete/whatevertheprofileisis` – Jamiec Jul 20 '15 at 15:17
  • And, for the answerer, answers in comments are not helpful. You did the right thing by answering, not commenting on, this question. However, what makes you think this question is about Angular? (referencing your update) – Jamiec Jul 20 '15 at 15:19
  • I wasn't sure it was the answer haha, Updated my answer with an information link with another possibility how to do it ( i wouldn't use it but its handy for information :) ) – Jean-Paul Jul 20 '15 at 15:20
-1

profile-id is in ID property of td table?? you can use jquery closest to get id from td near to your input was clicked.

by example

$("input").closest(td).attr("id") = your id
Patricio Jofre
  • 115
  • 1
  • 6
  • The `profile-id` is on the `input` based on the example given. `closest` takes a string (`"td"` not `td`). This does not answer the question. Yes, the downvote was me! – Jamiec Jul 20 '15 at 15:23