我需要从jquery ajax请求和其他一些标签中更新输入值,但是输入仅在第二次单击后才更新。我一直在寻找答案,但我可能输入内容丢失了焦点,当我再次单击时,输入内容又重新显示了,但是我不知道如何在输入上再次设置焦点
这是我的代码:
$(oe_website_sale).on('click', 'li.installment_term', function (ev) {
ev.preventDefault();
var term_id = $('li.installment_term.active').attr('id');
var $parent = $ul.closest('.js_product');
var price = $parent.find(".oe_price:first .oe_currency_value")[0].innerText;
var down_payment = $('input.down_payment');
ajax.jsonRpc('/calculate/term/load', 'call', {term_id, price})
.done(function (result) {
price_install.text(result.price_per_month);// This line is updating perfectly from the first click
down_payment.val(result.down_payment); // This line has now effect only after second click
down_payment.attr('min', result.down_payment);// This line is updating perfectly from the first click
});
});
和我的html代码:
<input type="number" name="down_payment" min="0" step="0.01"
class="form-control down_payment" value="0.00"/>