check click event for logout

This commit is contained in:
phyusin
2018-03-09 13:29:24 +06:30
parent 21d39349d3
commit 91e76c7381
2 changed files with 60 additions and 31 deletions

View File

@@ -20,33 +20,33 @@ $(document).ready(function() {
borderRadius: '0',
railBorderRadius: '0'
});
$('.delete').click(function(){
var method = $(this).attr('data-method');
var url = $(this).attr('data-ref');
var html_text = $(this).siblings( "#delete_text" ).html();
//var page = url.substring(url.lastIndexOf('/') + 1);
swal({
title: "Confirmation",
text: html_text,
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
html: true
}, function (isConfirm) {
if (isConfirm) {
$.ajax({
type: method,
url: url ,
success: function(data) {
location.href = data.url;
}
});
} else {
swal("Cancelled", "Your imaginary file is safe :)", "error");
}
});
});
// $('.delete').click(function(){
// var method = $(this).attr('data-method');
// var url = $(this).attr('data-ref');
// var html_text = $(this).siblings( "#delete_text" ).html();
// //var page = url.substring(url.lastIndexOf('/') + 1);
// swal({
// title: "Confirmation",
// text: html_text,
// type: "warning",
// showCancelButton: true,
// confirmButtonColor: "#DD6B55",
// html: true
// }, function (isConfirm) {
// if (isConfirm) {
// $.ajax({
// type: method,
// url: url ,
// success: function(data) {
// location.href = data.url;
// }
// });
// } else {
// swal("Cancelled", "Your imaginary file is safe :)", "error");
// }
// });
// });
// for Notificaiotn message
var placementFrom = $("#notify_message").attr('data-placement-from');

View File

@@ -51,13 +51,11 @@
</li>
<% end %>
<li>
<!-- <%if current_login_employee.role !="waiter" %> -->
<!-- <%end%> -->
<!-- <p class="delete waves-effect waves-block p-l-30 m-b-5" data-ref="<%=logout_path%>" data-method="delete">
<i class="material-icons font-10 logout_icon">exit_to_app</i>
<span class="font-18">Logout</span>
</p> -->
<p class="delete waves-effect waves-block p-l-30 m-b-5" data-ref="<%= logout_path %>" data-method="delete">
<p class="delete waves-effect waves-block p-l-30 m-b-5 logout" data-ref="<%= logout_path %>" data-method="delete">
<i class="material-icons font-7 logout_icon">exit_to_app</i>
<span class="font-15">Logout</span>
</p>
@@ -73,4 +71,35 @@
</a> -->
</div>
</div>
</nav>
</nav>
<script type="text/javascript">
$(function(){
$('.delete').click(function(){
var method = $(this).attr('data-method');
var url = $(this).attr('data-ref');
var html_text = $(this).siblings( "#delete_text" ).html();
//var page = url.substring(url.lastIndexOf('/') + 1);
swal({
title: "Confirmation",
text: html_text,
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
html: true
}, function (isConfirm) {
if (isConfirm) {
$.ajax({
type: method,
url: url ,
success: function(data) {
location.href = data.url;
}
});
} else {
swal("Cancelled", "Your imaginary file is safe :)", "error");
}
});
});
});
</script>