0

I have an element that I want update through ajax. The element is using jQuery ui buttonset function.

Now when I load the element with buttonset, the buttonset jQuery ui css no longer shows on the element.

I have tried using ON() but that didn't work either.

How can you have jQuery ui css with elements loading on the fly?

UPDATE:

Ok so I have an element with buttonset

$('#element').buttonset()

And an ajax call

$('.new_filter_button').click(function(){ // when a feature button is selected
    var serialize = $('#header_dropdown_make').serialize(); // takes all the values of the filter
    $.ajax({  
        type : 'POST',
        url  : 'http://localhost/ajax/new-filters.php', 
        data : serialize,
        success : function(data) {
            $("#new_results_toolbar").html(data);
        }
    }); 
});

The new new-filters.php will return the id element. It is replacing the old element with the new one on the fly in the DOM.

2
  • Can you add your code to jsfiddle? It is easier that way to see the issue. Commented Mar 27, 2014 at 0:27
  • Are you updating it or are you taking it out of the DOM and replacing it? If so, you need to restore all the proper CSS classes for it to retain its jQuery UI appearance. Commented Mar 27, 2014 at 0:33

1 Answer 1

1

I imagine the way you're doing this is removing the original markup and replacing with the new html via AJAX.

If that is true, what is happening is that the original $.button() "instance" is lost when you remove the element, and the new element loaded with AJAX was never passed to $.button().

I think you can fix this just by "re-linking" the updated element in the complete callback $.ajax provides.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.