我正在使用x-editable進行內聯編輯。當我通過ajax和x-editable更新值來獲得響應時,我發現覆蓋包含新的x-editable值的div非常困難。如何重寫x-editable ajax響應值?
例如,我的X-編輯鏈接看起來是這樣的:
<a href="#" id="freight">$100</a>
輸入我的彈出窗口,X-編輯提供再輸入值300.00
當我做編輯我的編輯,我進行如下操作:
$('#freight').editable({
validate: function(value) {
if($.trim(value) == '') return 'This value is required.';
},
type: 'text',
url: '{{ path('update_purchase_order_ajax') }}',
pk: {{ purchaseOrder.id }},
title: 'Enter Freight Value',
ajaxOptions: {
dataType: 'json'
},
success: function(response, newValue) {
// Update the purchase order amounts...
$('#freight').html('$' + newValue);
}
});
當x編輯完成後,顯示在頁面上的值現在爲300.00(不含$美元符號)。正如你可以在我的jQuery代碼中看到的,我試圖重寫x-editable在$('#freight')。html('$'+ newValue)中放置頁面的值。
由於某種原因,這是行不通的。我想要$ 300.00出現,而不是300.00。
不應該把\ $。這對我有點困惑 – Lamis