Sachini / freebase-suggest

Automatically exported from code.google.com/p/freebase-suggest
Other
0 stars 0 forks source link

Add hooks for customising the way results are ordered and displayed #7

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I want to use Freebase Suggest as a topic picker for my own site. As part of 
this, I want to alter 
its behaviour slightly - when showing a list of results, I would like to move 
items that have 
previously been used on my site to the top of the suggestions list and visually 
highlight them 
(with an asterisk).

My ideal way of doing this would be to include a JavaScript array of items that 
have already been 
used on my site (which will normally be somewhere between 1 and 100 items long) 
on the page, 
and then customise Freebase Suggest, intercepting the incoming list of 
suggestions and 
bumping any that match my hard-coded list of IDs up to the top.

To do this, I need customisation hooks that allow me to:

1. Intercept the results returned by freebase before they are rendered by the 
widget
2. Modify the DOM elements used by Freebase Suggest to populate the suggestion 
list, as they 
are being created.

These hooks would be useful for much more than just my example here.

Original issue reported on code.google.com by simon%si...@gtempaccount.com on 15 Aug 2009 at 10:02

GoogleCodeExporter commented 9 years ago
You should be able to accomplish this using the new freebase suggest which is 
now
hosted on freebaselibs.com. The latest version:
http://freebaselibs.com/static/suggest/0.9.4/index.html

you can do something like:

var base = {
  response: $.suggest.suggest.response
}

$.suggest("mysuggest", {

  response: function(data) {

    // you can modify the data here

    // and call super.response

    base.response.apply(this, [data]);

  }

});

Original comment by daep...@gmail.com on 17 Aug 2009 at 5:14

GoogleCodeExporter commented 9 years ago

Original comment by daep...@gmail.com on 17 Aug 2009 at 6:28