I have been using jQueryUI's auto complete for a while, but I'd like to 
switch to Bootstrap's type ahead.

In the view I had the following code:

<script type="text/javascript">
$(document).ready(function(){
  $(function() {$("#no_table_locality").autocomplete({source: 
"{{=URL('jqueryui', 'locality_autocomplete')}}",minLength: 2});});
});
</script>

and in a controller:

def locality_autocomplete():
    rows=db(db.locality.name.like(request.vars.term+'%'))\
    
.select(db.locality.name,distinct=True,orderby=db.locality.name).as_list()
    result=[r['name']for r in rows]
    return response.json(result)


I changed this code the following way:

<script type="text/javascript">
$(document).ready(function(){
  $("#no_table_locality").typeahead({source: "{{=URL('typeahead', 
'locality_typeahead')}}"});
});
</script>

and in the controller:

def locality_typeahead():
    rows=db(db.locality.name.like(request.vars.term+'%'))\
    
.select(db.locality.name,distinct=True,orderby=db.locality.name).as_list()
    result=[r['name']for r in rows]
    return response.json(result)


This doesn't work, most likely because the source isn't defined correctly. 
This is what the Boostrap documentation
says:

The function is passed two arguments, the query value in the input field 
and the process callback. The function 
may be used synchronously by returning the data source directly or 
asynchronously via the process callback's single argument.

How do I code this correctly to get it to work. I am using Bootstrap 2.3.1

Kind regards,

Annet

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to