I have the next script, "/cashflow/arrow/" calls a django view that gets the data and works with it. Then it returns the data that is loaded in the html.
The script works fine in the first click, but when I want to click a link again, nothing happens.
<script>
$(document).ready(function(){
var prev_months = {{ prev_months }}
var next_months = {{ meses_desp }}
function arrow(meses_ant, next_months) {
$.get("/cashflow/arrow/", { prev_months: prev_months, next_months: next_months},
function(data){
$("#cash_grid").html(data);
});
}
$("#dates_up").click( function() {
if (prev_months > 0) {
prev_months = prev_months - 1;
}
next_months = next_months + 1;
arrow(prev_months, next_months);
});
$("#dates_down").click( function() {
prev_months = prev_months + 1;
if (next_months > 0) {
next_months = next_months - 1;
}
arrow(prev_months, next_months);
});
})