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 6198261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:57:56+00:00 2026-05-24T03:57:56+00:00

How do you get a list of all projects from a model such as

  • 0

How do you get a list of all projects from a model such as Project.all and all the project.name’s in there moved to a listed in javascript which is then printed out using Jquery UI Autocomplete

Link to Jquery UI Autocomplete

$( " #tags " ).autocomplete({
            source: function(request, response){
            //pass request to server
            $.ajax({
                url: "/projects/project_list",
                dataType: "json",
                data: {
                    style: "full",
                    maxRows: 12,
                    term: request.term
                },
            minLength: 1,
            select: function( event , ui ) {
                                            log( ui.item ?
                                            ui.item.value : +  this.value );
                                            }
        });
  • 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-24T03:57:57+00:00Added an answer on May 24, 2026 at 3:57 am

    Think you are probably looking for something like this:

     def project_list  
       list=Project.all.map{|i|[i.name,i.id]}
      arr= [["No project",0]].concat(list.sort{|a,b| a[0]<=>b[0]}).to_json
      render :json =>arr
     end
    

    You then need to call this method from inside the js

         $("#some_input_id").autocomplete({
            source: function(request, response){
                //pass request to server
                $.ajax({
                    url: "/projects/project_list",
                    dataType: "json",
                    data: {
                        style: "full",
                        maxRows: 12,
                        term: request.term
                    },
                    success: function( data ) {
    #do stuff here
    }
    });
    });
    

    Here’s a relatively complete example of some that produces an autocomplete list of airports

       $("#airport, #station").autocomplete({
            delay: 1000,
            search: function(event,ui){
                tag = event.target.id
            },
            source: function(request, response){
                //pass request to server
                $.ajax({
                    url: "/tags/"+ tag +"/list",
                    dataType: "json",
                    data: {
                        style: "full",
                        maxRows: 12,
                        term: request.term
                    },
                    success: function( data ) {
                        response( $.map( data, function( item ) {
                            if (tag == "airport"){
                                return {
                                    label: item.airport.fd_name
                                }
                            }
                            else
                            {
                                return {
                                    label: item.station.fd_name
                                }
    
                            }
    
                        }));
                    }
                });
            },
            minLength: 2,
            open:   function( event, ui ) {
                stripe($(this));
            },
            close: function() {
                $( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
            }
        });
    

    And here’s the associated controller code:

    def list
        @tags= params[:tagclass].titleize.constantize.where("fd_name ilike ? ",params[:term]+"%").order('fd_name')
        render :json =>  @tags.to_json(:only=>[:fd_code, :fd_name]), :layout=>false
      end
    

    `

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

Sidebar

Related Questions

I want to get a list of all the forms in the project i
I have a project which has just assimilated several apps from other projects of
I have a User model which has many projects and a Project model which
i want to get list of all application or Threads attached with a process.For
How can I to get list of all wcf services running on a machine?
Looking to get a list of all the files (commit comments would be nice
How do I get a list of all files (and directories) in a given
How do I get a list of all the tables defined for the database
How do I get a list of all the headings in a word document
How do I get a list of all currently loaded assemblies? Closed as a

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.