Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

for load() if fix promblem

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

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.

Another solution may be this

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

200 or a higher number may need.

Try this:

   $('.elementClass').uniform();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top