简体   繁体   English

AJAX调用后formatCurrency不起作用

[英]formatCurrency not working after AJAX call

I am using format currency jQuery plugin to add a $ in front of some numbers. 我正在使用格式货币jQuery插件在某些数字前添加$ I also have a table that uses an AJAX call to sort the table. 我还有一个使用AJAX调用对表进行排序的表。 When the page loads initially, the $ is added correctly. 最初加载页面时,将正确添加$ But, when I sort the table, the function is not called and my numbers lose the $ . 但是,当我对表格进行排序时,不会调用该函数,并且我的数字会丢失$ Is there something like $(window).load for an AJAX call? 是否有类似$(window).load的AJAX调用?

I should mention that the table sorting is also done through a plugin, so I do not want to edit the plugin's files. 我应该提到表排序也是通过插件完成的,因此我不想编辑插件的文件。 I would like to add this to my main.js file just in case the plugin gets an update. 我想将其添加到main.js文件中,以防插件得到更新。

Here is what I have so far that is not working with the AJAX call: 到目前为止,这是我目前无法使用AJAX调用的内容:

(function($){
    $(window).load(function(){
        $('.currency, .amount-applied').formatCurrency({
            roundToDecimalPlace: 0
        });
    });
})(jQuery);

The AJAX call that sorts the table should have a callback function defined. 对表进行排序的AJAX调用应定义一个回调函数。 If so, that's where you want to put your formatCurrency() call. 如果是这样,那就是您要放置formatCurrency()调用的地方。 $(window).load() doesn't fire after an AJAX call. $(window).load()在AJAX调用后不会触发。

What plugin are you using to sort the table? 您使用什么插件对表格进行排序? If you point us in the right direction we can get you sorted (haha, see what I did there?) 如果您向我们指出正确的方向,我们可以为您排序(哈哈,看看我在那儿做了什么?)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM