Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8963239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:18:57+00:00 2026-06-15T16:18:57+00:00

I’m using JQuery UI Autocomplete for quick search widget. I have several grouped items

  • 0

I’m using JQuery UI Autocomplete for quick search widget. I have several grouped items like hotels, cities, areas etc. I could render categories, but I couldn’t link them. When I try, ui autocomplete plugin detect categories like items. That’s not problem, but when I focused them using up/down arrow or using mouse, it returns me an error like this:

"TypeError: item is undefined. this.liveRegion.text( item.value );"

How can I fix this? I try to use JQuery UI Autocomplete’s “focus” event with several methods (like ‘return false, e.stopPropagation or e.preventDefault‘), but it didn’t work

Here’s my code:

$.widget("custom.catcomplete", $.ui.autocomplete, {
        _renderMenu: function (ul, items) {
            var searchkey = "";
            var itemtype = "";
            var searchtype = "";

            var self = this, currentCategory = "";
            $.each(items, function (index, item) {
                if (typeof item.kelime != 'undefined') { searchkey = item.kelime; }
                if (item.category != currentCategory) {
                    if (item.category == "Bölge" || item.category == "Şehir") {
                        itemtype = "cat-bolgeler";
                    } else if (item.category == "Otel") {
                        itemtype = "cat-oteller";
                        searchtype = "otel";
                    } else if (item.category == "Yurt Dışı Tur") {
                        itemtype = "cat-ydtur";
                        searchtype = "yurtdisitur";
                    } else if (item.category == "Yurt İçi Tur") {
                        itemtype = "cat-yitur";
                        searchtype = "yurticitur";
                    } else if (item.category == "Cruise") {
                        itemtype = "cat-cruise";
                        searchtype = "cruise";
                    }
                    if (searchtype != "") {
                        ul.append("<li class='ui-autocomplete-category " + itemtype + "' id='" + item.searchid + "'><a href='/arama/" + searchkey + "?k=" + searchtype + "&q=" + searchkey + "'>" + item.category + "</a></li>");
                    } else {
                        ul.append("<li class='ui-autocomplete-category " + itemtype + "' id='" + item.searchid + "'>" + item.category + "</li>");
                    }
                    currentCategory = item.category;
                }
                self._renderItem(ul, item);
            });
        }
    });

    $(".hizliaratext").catcomplete({
        source: function (request, response) {
            $.ajax({
                url: '/filename.aspx',
                dataType: "json",
                contentType: "application/json; charset=utf-8",
                type: "get",
                data: { kelime: request.term },
                success: function (data) {
                    response($.map(data, function (item) {
                        return {
                            label: item.label,
                            searchid: item.searchid,
                            category: item.category,
                            link: item.link,
                            kelime: item.kelime
                        }
                    }));
                }
            });
        },
        minLength: 3,
        appendTo: "#hizliara",
        select: function (event, ui) {
            window.location = ui.item.link;
        },
        focus: function (event, ui) {
        }
    }).data("catcomplete")._renderItem = function (ul, item) {
        return $("<li>").data("item.autocomplete", item).append("<a>" + item.label + "</a>").appendTo(ul);
    };

Here’s the sample JSON response for “?kelime=anka“:

[{"searchid":2001,"label":"Alba Ankara Hotel","category":"Otel","link":"/otel-detay/alba-ankara-hotel","kelime":"anka"},{"searchid":2238,"label":"Ankara Madi İnci Hotel","category":"Otel","link":"/otel-detay/ankara-madi-inci-hotel"},{"searchid":2244,"label":"Madi Hotel Ankara","category":"Otel","link":"/otel-detay/madi-hotel-ankara"},{"searchid":2403,"label":"City Hotel Ankara","category":"Otel","link":"/otel-detay/city-hotel-ankara"},{"searchid":2404,"label":"Doğa Residence Ankara","category":"Otel","link":"/otel-detay/doga-residence-ankara"},{"searchid":6779,"label":"Ankara","category":"Şehir","link":"/ustaramaliste.aspx?y=6779"},{"searchid":6785,"label":"Ankara / Çankaya","category":"Bölge","link":"/ustaramaliste.aspx?y=6785"},{"searchid":14601,"label":"İzmir / Çankaya","category":"Bölge","link":"/ustaramaliste.aspx?y=14601"}]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T16:18:59+00:00Added an answer on June 15, 2026 at 4:18 pm

    Sounds (and looks) like you want the select/focus event for the category items (if this isn’t the case I’ll update my answer).

    The autocomplete widget internally expects list items to have item.autocomplete data associated with them. In order to get around the error, you could create your “category” items with the appropriate data. This will enable you to react to the select event and get rid of the error occurring on the focus event:

    Updated widget code:

    $.widget("custom.catcomplete", $.ui.autocomplete, {
        _renderMenu: function(ul, items) {
            var searchkey = "";
            var itemtype = "";
            var searchtype = "";
    
            var self = this,
                currentCategory = "";
            $.each(items, function(index, item) {
                if (typeof item.kelime != 'undefined') {
                    searchkey = item.kelime;
                }
                if (item.category != currentCategory) {
                    if (item.category == "Bölge" || item.category == "Şehir") {
                        itemtype = "cat-bolgeler";
                    } else if (item.category == "Otel") {
                        itemtype = "cat-oteller";
                        searchtype = "otel";
                    } else if (item.category == "Yurt Dışı Tur") {
                        itemtype = "cat-ydtur";
                        searchtype = "yurtdisitur";
                    } else if (item.category == "Yurt İçi Tur") {
                        itemtype = "cat-yitur";
                        searchtype = "yurticitur";
                    } else if (item.category == "Cruise") {
                        itemtype = "cat-cruise";
                        searchtype = "cruise";
                    }
                    if (searchtype != "") {
                        ul.append($("<li class='ui-autocomplete-category " + itemtype + "' id='" + item.searchid + "'><a href='/arama/" + searchkey + "?k=" + searchtype + "&q=" + searchkey + "'>" + item.category + "</a></li>").data("item.autocomplete", {}));
                    } else {
                        ul.append($("<li class='ui-autocomplete-category " + itemtype + "' id='" + item.searchid + "'>" + item.category + "</li>").data("item.autocomplete", {}));
                    }
                    currentCategory = item.category;
                }
                self._renderItem(ul, item);
            });
        }
    });
    

    Example: http://jsfiddle.net/J5rVP/20/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
This could be a duplicate question, but I have no idea what search terms
I have thousands of HTML files to process using Groovy/Java and I need to
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.