From 87efd7a592fdb68d991e96a0593e9391fdef793e Mon Sep 17 00:00:00 2001 From: Chirag Modi Date: Fri, 5 May 2017 18:11:42 +0530 Subject: [PATCH] add confirmation message on delete --- public/javascripts/all.js | 9 +++++++++ views/layout.pug | 1 + views/profile-lists.pug | 2 +- views/profile-view.pug | 2 +- 4 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 public/javascripts/all.js diff --git a/public/javascripts/all.js b/public/javascripts/all.js new file mode 100644 index 0000000..c0952ca --- /dev/null +++ b/public/javascripts/all.js @@ -0,0 +1,9 @@ +function confimrDelete(id) { + var r = confirm("Are you sure what to delete?"); + if (r == true) { + window.location.href='/profiles/delete/'+id; + return; + } else { + return false; + } +} diff --git a/views/layout.pug b/views/layout.pug index e5f0521..9784290 100644 --- a/views/layout.pug +++ b/views/layout.pug @@ -22,3 +22,4 @@ html script(src="https://code.jquery.com/jquery-3.1.1.slim.min.js") script(src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js") script(src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js") + script(src="/javascripts/all.js") diff --git a/views/profile-lists.pug b/views/profile-lists.pug index 170005a..286f5ad 100644 --- a/views/profile-lists.pug +++ b/views/profile-lists.pug @@ -51,7 +51,7 @@ block content p.card-text.font-weight-bold.text-center .alert.alert-success(role='alert') #[strong No Data Available] a.card-link(href='../profiles/edit/'+profile.id) Edit Profile - a.card-link(href='../profiles/delete/'+profile.id) Delete Profile + a.card-link(href='javascript:void(0);', onclick="confimrDelete(" + profile.id + ")") Delete Profile a.card-link(href='../profiles/view/'+profile.id) View Profile .card-footer.text-muted= profile.profile_create else diff --git a/views/profile-view.pug b/views/profile-view.pug index 2b5d3ab..7e948a4 100644 --- a/views/profile-view.pug +++ b/views/profile-view.pug @@ -72,7 +72,7 @@ block content .alert.alert-success(role='alert') #[strong No Data Available] .mt-5 a.card-link(href='/profiles/edit/'+profiles[0].id) Edit Profile - a.card-link(href='/profiles/delete/'+profiles[0].id) Delete Profile + a.card-link(href='javascript:void(0);', onclick="confimrDelete("+ profiles[0].id +")") Delete Profile .card-footer.text-muted= profiles[0].profile_create else h3 No Profile Created