JQuery Selected for Select Boxes - How to apply a style after AJAX loads a selection

So, I am trying to apply the Chosen jQuery plugin in the select box after loading it through XAJAX . Here is the code:

Usually I start loading on the page, and all the selection fields with the class are correctly formatted accordingly:

$(document).ready( function () {        
    $(".chzn-select").chosen();
});

Then I have a function that uses XAJAX to display a new selection window in the specified DIV on the page. It works great. HOWEVER, he was not chosen by the Chosen One, as it should be.

I also tried to add a delay because I read on some forums that this worked for some people. This does not work....

function getNewSelect(property_id){
    xajax_getNewSelect();
    $(".chzn-select-ajax").delay(5).chosen();
}

Does anyone have any ideas?

+5
source share
2

xajax?

delay , - .

, :

setTimeout(function() { $(".chzn-select-ajax").chosen(); }, 500);
+4
<script language="javascript" type="text/javascript">
    $(function () {
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(loadControlDuringAjax);
        loadControlDuringAjax();
    });
    function loadControlDuringAjax() {
        $(".chzn-select").chosen(); $(".chzn-select-deselect").chosen({ allow_single_deselect: true });
    }
</script>

, .

+1

All Articles