[Freebase-discuss] Freebase Suggest as an Autocomplete Front End

Dae Park daepark at google.com
Mon May 16 22:46:49 UTC 2011


You should be able to by extending the suggest widget...

var base = {
  _init: $.suggest.suggest.prototype._init,
  response: $.suggest.suggest.prototype.response,
  create_item: $.suggest.suggest.prototype.create_item
};

$.suggest("mysuggest",
          $.exnted(true, {}, $.suggest.suggest.prototype, {

            _init: function() {
              base._init.call(this);

              // modify/transform the this.options.ac_param
              // tailored to your service (service_url + service_path)
              console.log(this.options.ac_param);
            },

            response: function(data) {
              // transform the data to what the suggest widget expects
              console.log(data);
              base.response.call(this, data);
            },

            create_item: function(item_data, response_data) {
              // you can also overrwite create_item for rendering each
individual item
              // you should return an <li> element
              console.log(item_data);
              return base.create_item.call(this, item_data, response_data);
            }

          }));


Then you will have your own suggest called "mysuggest"...

$("#myinput").mysuggest(...)

-dae



On Mon, May 16, 2011 at 3:03 PM, Philip Kendall
<philip-freebase at shadowmagic.org.uk> wrote:
> On Mon, May 16, 2011 at 03:58:23PM -0600, Kevin Bache wrote:
>> My apologies if this has been answered before but I Googled around for an
>> hour and couldn't find much.
>>
>> Is it possible to use Freebase Suggest as a front end for an autocomplete
>> widget that isn't based on Freebase data?  I'm familiar with the service_url
>> option, but digging through the Javascript code, I couldn't figure out how
>> to construct request objects for my own data store or interpret the
>> resulting responses.  The reason that I ask, is that 1) I like the features
>> and format of Freebase Suggest, 2) I'd like to have several autocomplete
>> widgets with identical behavior, some of which pull from Freebase and some
>> which pull from other data stores.
>
> Practically, it's strictly for Freebase.
>
> If you had another server which implemented all the relevant Freebase
> APIs, you could point it to that. However, no such server exists and
> doing that would be more work than reimplementing Suggest from scratch,
> so...
>
> [ Taken from my answer at http://stackoverflow.com/questions/4623620 ]
>
> Cheers,
>
> Phil
>
> --
>  Philip Kendall <philip at shadowmagic.org.uk>
>  http://www.shadowmagic.org.uk/
> _______________________________________________
> You are receiving this message because you are subscribed to the Freebase-discuss mailing list.
> To post a message to the list: Freebase-discuss at freebase.com
> To unsubscribe, view archives, etc: http://lists.freebase.com/mailman/listinfo/freebase-discuss
>


More information about the Freebase-discuss mailing list