JQuery Migration – Plugin Autocomplete

The jQuery Autocomplete plugin got a successor recently, the jQuery UI Autocomplete. In this guide we’ll look at the old plugin API step-by-step, and how to migrate to the new API.

At first it may look like the new plugin supports barely any of the old options. We’ll see how all the old options can be implemented using the three new options and the six events.

The old plugin had two arguments: data or url, and options. Lets start with that data-or-url argument. With the new autocomplete plugin, you’ll just pass the data or url to the source option.

So, with the old plugin you’d have this code:

JavaScript:
$(“input”).autocomplete([“a”, “b”, “c”]);

And that becomes, easy enough:

JavaScript:
$(“input”).autocomplete({
source: [“a”, “b”, “c”]
});

Soucer: http://www.learningjquery.com/2010/06/autocomplete-migration-guide

Deixe um comentário

O seu endereço de e-mail não será publicado.