issa-tseng / awesomecomplete

A lightweight autocomplete plugin for jQuery. Autocomplete that doesn't suck — I think.
http://dontexplain.com/2009/08/jquery-plugin-lautocomplete/
52 stars 7 forks source link

how to use dataMethod #17

Open hoangnm89 opened 9 years ago

hoangnm89 commented 9 years ago

i dont know how to use dataMethod. i setup like this: $(function() { $('#friend_id2').awesomecomplete({ //more config dataMethod: dataMethod }); }); var dataMethod = function(term, $awesomecomplete, onData) { onData = [ { name: 'Ryan Lapin', email: 'ryan.lapin@albany.dundermifflin.com', phone: '(512) 829-4442' }, { name: 'Angela Kapoor', email: 'angela.kapoor@yonkers.dundermifflin.com', phone: '(435) 149-4341' }, { name: 'Pam Martin', email: 'pam.martin@buffalo.dundermifflin.com', phone: '(204) 189-7995' } ]; return onData; };

it didn't work for me. I want to call ajax and get data from server

issa-tseng commented 9 years ago

Call onData instead. Replace return onData; with onData([{ name: /* … */ }]);.

hoangnm89 commented 9 years ago

thanks for reply, but i still dont understand what you say: onData([{ name: /* … */ }]); write for me little bit of code to show how it work. thank you so much