From addb6b553444e9ea79f633d49cd9d23b64f961bd Mon Sep 17 00:00:00 2001 From: Aurélien Bompard Date: Feb 22 2017 17:21:45 +0000 Subject: Don't hardcode URLs in Javascript code --- diff --git a/hubs/templates/hubs.html b/hubs/templates/hubs.html index fda7f95..2e4ccb3 100644 --- a/hubs/templates/hubs.html +++ b/hubs/templates/hubs.html @@ -146,7 +146,7 @@

- + Add a widget

@@ -164,7 +164,7 @@

- + Add a widget

@@ -223,17 +223,14 @@ function make_widget_sortable() { }; function setup_add_btns() { - $(".add_widget").unbind(); - $(".add_widget").click(function() { - console.log($(this)); - var _pos = $(this).attr('data-position'); - + // Setup events for the "add widget" button. + $(".add_widget").click(function(e) { + e.preventDefault(); $.ajax({ - url: 'add?position=' + _pos, + url: $(this).attr('href'), dataType: 'html', success: function(html) { $('#edit_modal_content').html(html); - $('#edit_modal').modal(); }, error: function() { $('#edit_modal_content').html( @@ -244,8 +241,10 @@ function setup_add_btns() { ); console.log('error'); console.trace(); - $('#edit_modal').modal(); }, + complete: function() { + $('#edit_modal').modal(); + } }); return false; });