Mailinglist Archive: yast-devel (77 mails)

< Previous Next >
[yast-devel] a few notes on autocompletion
  • From: "Duncan Mac-Vicar Prett" <dmacvicar@xxxxxxx>
  • Date: Thu, 10 Dec 2009 18:27:16 +0100
  • Message-id: <200912101827.16918.dmacvicar@xxxxxxx>

After playing some days with forms and the users module in order to achieve
the following goals:

- autocompletion of form data
- examples for fields
- browser side validation

I want to share some results of those experiments and how they affect our

The first limitation I found is mostly likely present in various models.

Users.find(:all) returns less data than Users.find(id), only the username and
something else. If you want to autocomplete/suggest all known login shells (
something like Users.find(:all).map { |x| x.login_shell } ) you need a way on
the client side to get all login shells. I ended modifying the /users service
- accept ?attributes[]=attr1&attributes[]=attr2... so that the caller could
chose which attributes to insert
- be sure that it was able to return json

Once you have that, doing autocompletion is trivial, but very repeat-yourself
prone. Biggest problem is that you can't call from the browser the rest-
service unless:

- you set the url of the resource in the view
- you use JSON-P, using $.getJSON and setting a jsonp callback ( )

Or you can create an action in the controller which calls the service and
returns the result. I can't get the jsonp call to actually process the data.

Then you need to set the right autocomplete data in the javascript
document.ready callback inlined in the view (at least until we solve the
problem I mentioned in opensuse-ruby mailing list ), by using
jquery.autocomplete calls on the right form fields, giving the autocomplete
data you got from the service or the controller action

We can avoid duplication of Javascript by emulating what rails implements with
protoype, so that you specify the autocompletions in the model class. For that
we would need to swtich from find_proxy to a real User class using the class
Martin Kudlvasr and Martin Vidner where working on. Once you have a model we
could use something like:

combined with the jquery.autocomplete plugin to achieve a more or less
standard to apply validation to our forms.

Any ideas?

Duncan Mac-Vicar P. - Engineering Manager, YaST
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nuernberg)

To unsubscribe, e-mail: yast-devel+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-devel+help@xxxxxxxxxxxx

< Previous Next >
Follow Ups