I have configured an autocomplete as follows:
- $("#userlookup").autocomplete({
- delay: 500,
- source: function( request, response ) {
- request.listtype = distribution.LISTTYPE_BCC;
- request.group = distribution.GROUP_CECIDS;
- request.maxRows=10;
- lookupEmails(request,response);
- },
- minLength: 2,
- select: add2Distribution
- });
- function lookupEmails(request,callback){
- var maxr = (request.maxRows?request.maxRows:1);
- $.ajax({
- url: path_controller,
- dataType: "json",
- data: {
- funct: "lookupemails",
- maxRows: maxr,
- query: request.term,
- group: request.group
- },
- success: function( data ) {
- callback($.map( data, function( item ) {
- return {
- label: item.personal?item.personal:item.email.personal,
- value: "",
- listtype: request.listtype,
- group: request.group,
- emailobj: item
- };
- }));
- },
- error: function(xhr,err){
- alert("ERROR:\nreadyState: "+xhr.readyState+"\nstatus: "+xhr.status+"\nresponseText: "+xhr.responseText);
- }
- });
- }
- function add2Distribution(event,item,buildingconfirmed){
- if (event && !item)
- item = event;
- if (item.item)
- item = item.item;
- if (item){
- var row = get_rowArray(item);
- $("#dist"+item.listtype+"_datatable").dataTable().fnAddData([row]);
- distribution.add(item.listtype,item.group,item.emailobj);
- }
- }
- }
Everything works perfectly the "first time through". The user types, the "
lookupEmails" ajax returns the data, the user makes a selection, the selection data is passed to "
add2Distribution", and the autocomplete is cleared.
The user then wants to add a second selection:
The user types, the "
lookupEmails" ajax returns the data, the user makes a selection... nothing. I put in break points to confirm that my "add2Distribution" method is not being called.
This worked in 1.8; but I'm guessing the "bug fixes" in 1.9.2 changed the behavior?
Do I need to somehow "reset" the autocomplete object after calling my add2Distribution the first time? I tried adding a return and that didn't seem to do anything.
Any ideas?
THANKS!