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

  • SEARCH
  • Home
  • 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 3694320
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:28:57+00:00 2026-05-19T04:28:57+00:00

I need a to use an autocomplete in rails application. Which use the combobox

  • 0

I need a to use an autocomplete in rails application. Which use the combobox as source. I used jquery autocomplete and combobox.

But i need an extra feature. Suppose we type “Apple” and it is not available in auto-complete search it shows a new item in the list named “Create New Apple”, if we select it triggers a JavaScript event. so that we can open some dialog to add it.

Moreover the autocomplete can also be updated after rendering. Means if we add new record, it can also be populated in the list.

Hope to get good stuff from you guys.

  • 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-05-19T04:28:58+00:00Added an answer on May 19, 2026 at 4:28 am

    I full filled my scenario with this code. I modified the code from the jquery site, refactor the change event to.

     auto_obj.change = function(event, ui) {
           if (!ui.item) {
          var matcher = new RegExp("^" + $.ui.autocomplete.escapeRegex($(this).val()) + "$", "i"),
                        valid = false;
          select.children("option").each(function() {
             if ($(this).text().match(matcher)) {
                this.selected = valid = true;
                   return false;
             }
          });
          if (!valid) {
              // Trigger the event for value not found
              $(select).trigger('autocompletenotfound', $(this).val());
    
              // remove invalid value, as it didn't match anything
              $(this).val("");
              select.val("");
              input.data("autocomplete").term = "";
              return false;
          }
      }
    }
    

    and in the source function

    auto_obj.source = function(request, response) {
                    var matcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), "i");
                    var match = false;
    
                    response(select.children("option").map(function(i, value) {
                        var text = $(this).text();
                        if (this.value && ( !request.term || matcher.test(text) )) {
                            match = true;
                            return {
                                label: text.replace(
                                        new RegExp(
                                                "(?![^&;]+;)(?!<[^<>]*)(" +
                                                        $.ui.autocomplete.escapeRegex(request.term) +
                                                        ")(?![^<>]*>)(?![^&;]+;)", "gi"
                                                ), "<strong>$1</strong>"),
                                value: text,
                                option: this
                            };
                        }
                        if (!match && i == select.children("option").size() -1 && self.options.allow_new ) {
                            return {
                                label:'Create new <strong>'+ input.val() +'</strong>',
                                value: input.val(),
                                option: null
                            };
                        }
                    }));
                };
    

    This fulfilled my requirement. Hope will be help full for some one else.

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

Sidebar

Related Questions

I need a text input field which does not use the autocomplete function -
I'm trying to use the AutoComplete feature of JQuery to update multiple fields on
I'm attempting to use JQuery autocomplete and need to get the id of the
I'm attempting to use jQuery's autocomplete feature, and after reading several posts I still
I am requesting youtube search terms for use with jquery autocomplete, but am having
I try to use autocomplete jquery-ui script, but from the documentation it's explain that
I'm using the jQuery UI Autocomplete widget. I need to use the selected text
I am using jquery autocomplete combobox and everything is ok. But I also want
I need to use an alias in the WHERE clause, but It keeps telling
I need to use NSImage which appears need to be imported from <AppKit/AppKit.h> .

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.