Showing posts with label Jquery Autocomplete suggest size is displayed larger than the textbox. Show all posts
Showing posts with label Jquery Autocomplete suggest size is displayed larger than the textbox. Show all posts

Thursday, June 5, 2014

Jquery Autocomplete suggest size is displayed larger than the textbox

When you use Jquery to make an autocomplete, IE displays the width of the suggest window lager than the input box.To make the suggestion window smaller you can apply code as shown below.

 $(function () {

 $("#txtSearch").autocomplete({
            source: function (request, response) {
                $.ajax({

                    contentType: "application/json; charset=utf-8",
                    dataType: 'JSON',
                    url: '../SearchEmployee.asmx/GetEmployeeSuggestionList',
                    type: "POST",
                    data: '{empCode: "' + request.term + '"}',
                    dataType: "json",

                    success: function (data) {
                        response($.map(data.d, function (item) {
                            return {
                                label: item,
                                value: item
                            }
                        }))
                    }
                });

            }            minLength: 1,
            open: function(event, ui)
            {
                $("#ctl00_cphMobileMainContent_txtSearch").autocomplete("widget").css("width", "300px"); 
            }       
 });
});

cheers
Samitha