diff --git a/static/js/app/campaigns.js b/static/js/app/campaigns.js index c3a64ee0..1cf81a17 100644 --- a/static/js/app/campaigns.js +++ b/static/js/app/campaigns.js @@ -8,6 +8,8 @@ var labels = { "Error": "label-danger" } +var campaigns = [] + // Save attempts to POST to /campaigns/ function save() { groups = [] @@ -16,7 +18,6 @@ function save() { name: group[0] }) }) - console.log(groups) var campaign = { name: $("#name").val(), template: { @@ -52,6 +53,16 @@ function dismiss() { $("#groupTable").dataTable().DataTable().clear().draw() } +function deleteCampaign(idx) { + if (confirm("Delete " + campaigns[idx].name + "?")) { + api.campaignId.delete(campaigns[idx].id) + .success(function(data) { + successFlash(data.message) + load() + }) + } +} + function edit(campaign) { // Clear the bloodhound instance group_bh.clear(); @@ -90,7 +101,8 @@ function edit(campaign) { $(document).ready(function() { api.campaigns.get() - .success(function(campaigns) { + .success(function(cs) { + campaigns = cs $("#loading").hide() if (campaigns.length > 0) { $("#campaignTable").show() @@ -104,7 +116,7 @@ $(document).ready(function() { "