Solved

Coldfusion Powered Bootstrap Typeahead

Posted on 2013-12-09
5
927 Views
Last Modified: 2013-12-12
Since I can't use coldfusion "autosuggest" with Railo, I need help in getting this to work with bootstrap typeahead and any help is appreciated!

The following is example code that works but is not dynamic. I need to integrate the query below.

------------------
<input
                    type="text"
                    class="span4 basicTypeahead"
                    placeholder="What's your favorite US State?"
                    autocomplete="off"
                    data-provide="typeahead"
                />

Open in new window


How can I get the results of a cfquery to populate the bootstrap typeahead? Code examples appreciated!
 <script type="text/javascript">
        var dataset = ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'District of Columbia', 'Florida'];
        $(function(){
            $(".basicTypeahead").typeahead({
                source: dataset
                ,items: 10
            });
        });
    </script>

Open in new window



My query

      <cfquery datasource="myds" name="data">
            SELECT ID
            FROM res
            WHERE Trim(ID) LIKE Trim('#ARGUMENTS.search#%')
            ORDER BY ID
      </cfquery>
0
Comment
Question by:Bang-O-Matic
  • 2
  • 2
5 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 39707726
could you provide a link to a simple test page
0
 

Author Comment

by:Bang-O-Matic
ID: 39709080
Hi leakim971,

Here is a link to test page    http://macongahomes.com/test2.cfm

Thanks for your help!
0
 
LVL 16

Expert Comment

by:Gurpreet Singh Randhawa
ID: 39713240
in your dataset, store the results of the query using a valuelist function, it will give you comma separated values and then you can use them
0
 
LVL 16

Accepted Solution

by:
Gurpreet Singh Randhawa earned 500 total points
ID: 39713242
Like this

 var dataset = [<cfoutput>#quotedValueList(myquery.ciitiesName)#</cfoutput>];
0
 

Author Closing Comment

by:Bang-O-Matic
ID: 39714089
Works Perfectly! Thank you!
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question