I am having a lot of trouble with my code. This is a template that is served up from by Django backend.
{% load staticfiles %}
<html>
<head>
{% csrf_token %}
<title>Tempo</title>
<link rel="stylesheet" type="text/css" href="{% static "css/styles.css" %}">
<link rel="stylesheet" type="text/css" href="{% static "css/bootstrap.min.css" %}">
</head>
<body>
<div id="header">
<img id="logo" src="{% static "img/logo_wt.svg" %}"/>
</div>
{% csrf_token %}
<form id="myform" action="/" method="POST" enctype="multipart/form-data">
{% csrf_token %}
<input type="file" name="csvFile" id='csv'>
<input type="submit" value="Submit">
</form>
<button class='firebutton'>Add buttons</button>
<div class="fucking">{% autoescape off %}{{ data }}{% endautoescape %}</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="http://johnny.github.io/jquery-sortable/js/jquery-sortable.js"></script>
<script src="{% static "js/jquery-sortable.js" %}"></script>
<script>
$(document).ready(function(){
$('td').on('click', function(){
$(this).attr('contenteditable','true');
})
$('.firebutton').on('click', function(){
$('tbody').find('tr').each(function(){
$(this).append('<button type="button" id="remove" class="btn btn-default btn-lg good">' +
'<span class="glyphicon glyphicon-minus" aria-hidden="true"></span>' +
'</button>')
})
})
$('#remove').on('click', function(){
console.log("button clicked")
})
})
</script>
</body>
</html>
After a POST
my application responds with a html table
. Then what happens is if someone clicks on .firebutton
I add a button to every row in the table, except for the header. Now what I want to do is add functionality that removes a row. I was testing this by having a console.log for every newly added button click, but this doesn't work. If I put it in callback for the .firebutton
listener then it works, but only once. Anyone know whats going on here?