2015-07-20 33 views
0

我使用上刪除通話如何在此腳本的isconfirm方法中調用URL?

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

,這是它的運行

$(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"); 
       } 
      }); 
     }); 

    }) 

問題腳本一個onclick的是,我不知道如何獲得url期間運行isConfirm函數。我將該行的profileID傳遞給profile-id的url。我怎樣才能撥打我需要的/OBProfile/Delete/"profileid"?這是通過使用SweetAlert

+0

可以使用$。員額和編制網址。 – ashokd

+0

「profile-id」屬性是什麼?你通常會如何閱讀這些信息? – Jamiec

+0

這是[答案](http://stackoverflow.com/a/31519928/572827)針對您之前詢問過的相同問題。 – lshettyl

回答

1

你是什麼意思的「致電網址」,你的意思是去它?

這將這樣進行:

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

更新評論

後,我覺得這會派上用場。 AngularJS. How to call controller function from outside of controller component

+0

我需要運行具體的URL'/ OBProfile/Delete/whatevertheprofileisis',以便它擊中控制器並正確回發。 – TheDizzle

+0

@ TheDizzle - 這是正確的答案,只需將'http:// www.google.com'換成'/ OBProfile/Delete/whatevertheprofileisis' – Jamiec

+0

而對於回答者來說,評論中的回答是無用的。你通過回答,而不是評論這個問題做了正確的事情。但是,是什麼讓你認爲這個問題是關於Angular的? (引用你的更新) – Jamiec

-1

profile-id是在td表的ID屬性? 你可以使用jquery最接近從td獲取id的方式來輸入被點擊。

舉例

$("input").closest(td).attr("id") = your id 
+0

'profile基於給出的例子,「輸入」在「輸入」上。 「最接近」採用一個字符串('「td」'而不是'td')。這並沒有回答這個問題。是的,downvote是我! – Jamiec