diff --git a/smash/web/static/js/subject.js b/smash/web/static/js/subject.js index bfee2f14996e3bbf51dce37beb3796e0304d7993..1cc539c908db2fbfbef26a52cb0113663ec24bab 100644 --- a/smash/web/static/js/subject.js +++ b/smash/web/static/js/subject.js @@ -13,7 +13,7 @@ function createColumn(dataType, name, filter, visible, renderFunction) { }; } -function getColumns(type) { +function getColumns(type, getSubjectEditUrl) { var result = []; // don't confuse end user // result.push(createColumn("id", "Id", null, false)); @@ -29,7 +29,9 @@ function getColumns(type) { result.push(createColumn("information_sent", "Info sent", "yes_no_filter", true)); result.push(createColumn("type", "Type", "type_filter", true)); result.push(createColumn("id", "Edit", null, true, function (data, type, row, meta) { - return '<a href="#" type="button" class="btn btn-block btn-default">Edit</a>'; + var url = getSubjectEditUrl(row.id.toString()); + + return '<a href="' + url + '" type="button" class="btn btn-block btn-default">Edit</a>'; })); for (var i = 1; i <= 8; i++) { var renderFunction = (function () { @@ -207,11 +209,6 @@ function createSubjectsTable(params) { order: [[0, 'desc']] }); - $('#table tbody').on('click', 'a', function () { - var data = table.row($(this).parents('tr')).data(); - window.location.href = getSubjectEditUrl(data.id.toString()); - }); - // Apply the search table.columns().every(function () { var that = this; diff --git a/smash/web/templates/subjects/index.html b/smash/web/templates/subjects/index.html index 5d1b71485ed61161555b8cf9ce0b087ae1cf0865..7f97eb8619ff275cbe4f294b43ee2449b76a966e 100644 --- a/smash/web/templates/subjects/index.html +++ b/smash/web/templates/subjects/index.html @@ -53,13 +53,12 @@ {% endfor %} createSubjectsTable({ - getSubjectEditUrl: getSubjectEditUrl, worker_locations: worker_locations, subject_types_url: "{% url 'web.api.subject_types' %}", locations_url: "{% url 'web.api.locations' %}", subjects_url: "{% url 'web.api.subjects' list_type %}", tableElement: document.getElementById("table"), - columns: getColumns("{{ list_type }}"), + columns: getColumns("{{ list_type }}", getSubjectEditUrl), checkboxesElement: document.getElementById("visible-column-checkboxes") }) ;