당신은 callback
이벤트를 사용하여 합계를 계산하기 위해 적절한 이벤트 핸들러를 할당해야합니다. 작동하는이 코드를 확인하고 필요하다고 생각되면 추가 작업을 추가하십시오. 코드가 매우 이상하지만 어쨌든 작동합니다. 함수 tally
은 전역 함수로 onrender
$(function(){ ... });
블록 외부에 정의해야합니다.
가 이
<script type="text/javascript">
function tally (selector) {
$(selector).each(function() {
var total = 0,
column = $(this).siblings(selector).andSelf().index(this);
$(this).parents().prevUntil(':has(' + selector + ')').each(function() {
total += parseFloat($('p#sum:eq(' + column + ')', this).html()) || 0;
})
$(this).html(total);
});
}
$(function() {
tally('p#subtotal');
tally('p#total');
});
</script>
<script type="text/javascript" charset="utf-8">
$(function() {
$('.editable_number').editable(function(value, settings) { return(value); }, {
type : 'number',
style : "inherit",
callback: function() {
tally('p#subtotal');
tally('p#total');
}
}
);
$('.editable_textarea').editable(function(value, settings) { return(value); }, {
type : 'textarea',
width: '200',
height: '20',
submit : 'OK',
style : "inherit"
});
});
</script>
감사 반사, 내가 밖으로 시도하고 정확히 내가 의미로 작동, 당신은 내가 많이 향상시킬 필요가, 내 코드가 좀 지저분 알고 은데하지만, 코드의 단지 몇 행과 당신 당신이 한 일을 아주 잘 설명해주었습니다. 감사합니다. – Koala7
다행입니다. :) – Reflective