Jquery Uniform Update doesn't work

走远了吗. 提交于 2019-12-07 01:10:22

问题


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

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.

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.

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

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.


回答1:


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.

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




回答2:


for load() if fix promblem

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



回答3:


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.




回答4:


Another solution may be this

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

200 or a higher number may need.




回答5:


Try this:

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


来源:https://stackoverflow.com/questions/7868101/jquery-uniform-update-doesnt-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!