fabiomcosta / mootools-meio-autocomplete

A complete mootools Autocomplete plugin
http://www.meiocodigo.com/projects/meio-autocomplete/
32 stars 14 forks source link

decouple request from plug-in #13

Closed kilianc closed 12 years ago

kilianc commented 12 years ago

would be super nice to separare the request from the plug-in passing some handler

fabiomcosta commented 12 years ago

you wanna do the request using jsonp?

kilianc commented 12 years ago

jsonp / iFrame(ish) / websocket You can provide a simple interface to implement, so people can wrap their own data model :)

fabiomcosta commented 12 years ago

ok cool, now you can pass a function as the data. This source function will receive the inputed text as the first argument and the second argument will be a callback that should be called with the data as it's first argument, like this:

var autocomplete = new Meio.Autocomplete($('input-id'), function(text, complete) {
  // here you could create a request the way you want
  // you just need to call the complete function with the data
  complete(['some', 'other']);
});

Thank you very much!

kilianc commented 12 years ago

@fabiomcosta as usual you are super awesome! I am going to use it with socket.io :)

fabiomcosta commented 12 years ago

wow thank you man! this comment made my day :)