Auto-suggest with MJT – two demos

Nick’s demo

The latest version of MJT supports auto-complete. See Nick’s simple example.

Will’s demo

image Here’s my example (currently specific to films) Notice how the thumbnail updates as you navigate the menu 🙂 I had to add an extra ‘onchange’ hook, see source code for details.

Advertisements

2 Responses to Auto-suggest with MJT – two demos

  1. daepark says:

    Hi Will,
    I think Nick’s example is using mql to do prefix matching. We also have an autocomplete service that’s not really documented. If you try autocompleting on freebase.com, you should be able to see the call to that service using firebug. Anyway, I’ve implemented a mjt.Task to do this:

    // mjt.Task for /api/service/autocomplete
    fb.AutocompleteTask = function(prefix, type, category) {
    mjt.Task.apply(this);
    if (!type) type = “/common/topic”;
    if (!category) category = “instance”;
    this.values = {prefix: prefix, type: type, category: category,
    disamb: 1, limit: 10, get_all_types: 0} // defaults
    };
    fb.AutocompleteTask.prototype.enqueue = function() {
    var req = this; // for closure
    var path = “/api/service/autocomplete”;
    mjt.callback_script_get(mjt.service_url, path, this.values,
    function (o) {
    mjt.parse_metaweb_script_response(req, o);
    });
    };

  2. Will Moffat says:

    Hi Dae, thanks for the code snippet. I’ll try and make some time to make another example using your mjt.Task It will be interesting to compare the performance.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: