开发者

Autocompleter for Mootools to set multiple form values

I need a Mootools based autocompleter that retrieves data by ajax, and will fill in multiple form input elements when an option is selected. I.E, a user searches for "foo", and one of the options might be "foobar", which has associated with it the variables objecttype AND objectid, both of which need to be set in the form when the user clicks on "foobar".

I've been looking at two autocompleters: Meio.Autocomplete and AutoCompleter as my best bet, but neither of them really seem to handle what I need them to handle.

I'm considering either rewriting/extending one of those, or possibly using the Meio version (which handles a single value) and storing my multiple variable in the form in one field, possibly as a json object that can be parsed client side with json开发者_如何学PythonParse and inserted into the form with an additional function after the selection is made.

Does anyone know of a simpler solution?


You could use the Meio.Autocomplete's onSelect event with an identifier, that JSON encodes all of the needed properties.

var data = [
    {value: 'name1', identifier: {
        id: 'id1',
        type: 'type1'
    }},
    ...
}

I made a quick example

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜