我有下一个脚本,“/ cashflow/arrow /”调用一个django视图来获取数据并使用它。然后它返回在html中加载的数据。.click()事件仅在第一次执行
该脚本在第一次点击中工作正常,但是当我想再次单击链接时,没有任何反应。
<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);
});
})
谢谢佩德罗!它工作! – mfalcon 2010-09-16 23:07:59
'.live()'在1.9+版本中被删除,正如链接文档中所述('.on()'现在是首选)。 – 2013-03-06 20:58:40