jQuery   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了jquery – 如何覆盖x-editable ajax响应值?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用x-editable进行内联编辑.当我通过ajax和x-editable更新值以获得响应时,我发现很难覆盖包含新的x-editable值的div.

例如,我的x-editable链接如下所示:

<a href="#" id="freight">$100</a>

我在x-editable提供的弹出窗口中输入我的编辑,然后输入值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-editable完成后,页面显示的值现在为300.00(没有$dollar符号).正如你在我的jquery代码中看到的那样,我试图覆盖x-editable的值,用$(‘#furrency’)放置页面.html(‘$’newValue);

由于某种原因,这是行不通的.我希望300.00美元出现,而不是300.00.

解决方法

您需要做的是阻止显示方法覆盖您的成功方法.
display: function(value,response) {
  return false;   //disable this method
},newValue) {
  $(this).html('$' + newValue);
}

在服务器端,您的JSON应该是这样的,{newValue:< value>}

大佬总结

以上是大佬教程为你收集整理的jquery – 如何覆盖x-editable ajax响应值?全部内容,希望文章能够帮你解决jquery – 如何覆盖x-editable ajax响应值?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: