简体   繁体   中英

Chosen- on Ajax loaded select

I have the select drop-down element which is loaded dynamically from ajax call, I want to search option on that select. I used Chosen jquery plugin for my select, but that doesn't work since select element was not available(loaded on ajax response) when chosen loaded during document ready function.

I tried explicitly call jQuery(".chosen").chosen(); after div loaded in Ajax but that also didn't help.

My Ajax call is:

$.ajax({type: "POST",
            url: url,
            data: "action=getVMList,
             success: function(response) {              
                $('#vmList').innerHTML=response;

                 //Explicitly call chosen after ajax response. 
                 jQuery(".chosen").chosen();

                }       
        }); 

Response DIV for ajax is

<select class="AllVmList chosen" multiple id="select4${index}" >
    <c:forEach var="vm" items="${vmList}">
        <option><c:out value="${vm}"/></option>
    </c:forEach>
</select>

Seems issue was with some cache. Worked

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM