Jquery 统一更新不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7868101/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 00:23:06  来源:igfitidea点击:

Jquery Uniform Update doesn't work

jqueryajaxuniform

提问by Revenant

I'm using jquery uniform on one of the project I'm working on. Since this is admin panel, I truly don't have option to show. I will explain my problem

我正在我正在从事的项目之一上使用 jquery 统一。由于这是管理面板,我真的没有选择显示。我会解释我的问题

What I'm trying to do is quite simple. I'm adding some form elements (like select, check box, text input) to the page with ajax.

我想要做的很简单。我正在使用 ajax 向页面添加一些表单元素(如选择、复选框、文本输入)。

Every single thing works except re-styling those dynamically added form elements.

除了重新设计那些动态添加的表单元素之外,每件事都有效。

function step2 () {
    $.post( siteUrl + "includes/ajax/members/add-subscription.php?do=step2", $("#selectedSubscribers").serialize(), function( data ) { 
        $('.step2_content').html(data);
        $.uniform.update(); 
    });
 }

Anyone experienced similar problem? Even my onClick, onChange functions are working without a problem (dynamically added form elements), it is just, $.uniform.update();doesn't seem to work.

有人遇到过类似的问题吗?甚至我的 onClick、onChange 函数都可以正常工作(动态添加的表单元素),只是,$.uniform.update();似乎不起作用。

I thought processing data could take longer time so $.uniform.update(); is called before data is processed so I tried $.ajaxwith async: falsewith no luck.

我认为处理数据可能需要更长的时间,所以 $.uniform.update(); 数据被处理之前,所以我试着叫$.ajaxasync: false没有运气。

I will be glad if anyone who experienced such problem or who knows the solution could help me out with this problem.

如果任何遇到过此类问题或知道解决方案的人可以帮助我解决这个问题,我会很高兴。

Thank you in advance.

先感谢您。

回答by Sean Carpenter

When $.uniform()is first called, it collects all the specified elements into an internal array of affected elements. When you call $.uniform.update()it simply restyles those elements that were already collected.

$.uniform()第一次调用时,它收集了所有指定元素到受影响的元素的内部阵列。当您调用$.uniform.update()它时,只需重新设置那些已经收集的元素的样式。

To add additional elements, you may need to call $.uniform()again, passing a selector identifying only those new, dynamically added elements.

要添加其他元素,您可能需要$.uniform()再次调用,传递一个仅标识那些新的、动态添加的元素的选择器。

回答by dpolyakov

for load() if fix promblem

对于 load() 如果修复问题

$('#dialog').load(url + ' #forload', function() {$('#dialog').find('select').uniform(), $('#dialog').find('input:checkbox').uniform()})

回答by hotohoto

Have you tried this?

你试过这个吗?

$.uniform.update("#select_element_id");

In my case, the problem was solved.

就我而言,问题解决了。

Being old the version of uniform, may cause your problem.

旧的制服版本可能会导致您的问题。

回答by Jaskaran singh Rajal

Try this:

尝试这个:

   $('.elementClass').uniform();

回答by Teodoros

Another solution may be this

另一个解决方案可能是这样

setTimeout("$('.uniform_element').uniform();",200);

200 or a higher number may need.

可能需要 200 或更多。