Jquery Uniform Update doesn't work

Revenant picture Revenant · Oct 23, 2011 · Viewed 28.2k times · Source

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.

Answer

Sean Carpenter picture Sean Carpenter · Oct 23, 2011

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.