Issue
I am using select2.js Version: 3.4.3 with bootstrap I have one drop down.
When I click on drop down i got list with search text fields.
But I my cursor not focused on search text fields.
<form:select path="yearAge" id="yearAgeId"
cssClass="form-control search-select static-select">
<form:option value="">Years</form:option>
<c:forEach var="i" begin="1" end="125" >
<form:option value="${i}" label="${i}"></form:option>
</c:forEach>
</form:select>
$(".search-select.static-select").select2({
placeholder: $(this).attr('placeholder'),
allowClear: true
});
When I click on dropdown cursor focus should set to search text field automatically .
Thank you...!!!!!
Solution
This issue can be resolve by using the setTimeout() fucntion to delay the focus() execute time, we can achieve this by modifying a function in select2.js at line # 3321
container.on('open', function () {
self.$search.attr('tabindex', 0);
//self.$search.focus(); remove this line
setTimeout(function () { self.$search.focus(); }, 10);//add this line
});
Answered By - YOusaFZai
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.