[Proto-Scripty] autocomplete variant

2008-12-07 Thread macsig

Hello guys,
I'm trying to implement a variant of the classic autocomplete but I
can't make it works.
Basically what I want is to show for each element that matches with
the written text the element name and a checkbox (having the element
id as a value).
For instance, if my table contains:

ID  | NAME
1   | Tom
2   | Timmy
3   | John
4   | Nick
5   | Theodora

When I digit 'T' on my textfield the div called friends should be
populated with

[] Tom
[] Timmy
[] Theodora



Can someone help me out with this? Any help is welcome.

thanks and have a nice day!


Sig



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: autocomplete variant

2008-12-08 Thread macsig

Thanks Colin for your reply.

Your second option sounds exactly what I need.
I try to make it works.


Have a nice day.




On Dec 8, 3:49 am, ColinFine [EMAIL PROTECTED] wrote:
 On Dec 8, 3:05 am, macsig [EMAIL PROTECTED] wrote:

  Hello guys,
  I'm trying to implement a variant of the classic autocomplete but I
  can't make it works.
  Basically what I want is to show for each element that matches with
  the written text the element name and a checkbox (having the element
  id as a value).
  For instance, if my table contains:

  ID  | NAME
  1   | Tom
  2   | Timmy
  3   | John
  4   | Nick
  5   | Theodora

  When I digit 'T' on my textfield the div called friends should be
  populated with

  [] Tom
  [] Timmy
  [] Theodora

  Can someone help me out with this? Any help is welcome.

  thanks and have a nice day!

 There are several separate parts of this:
 - generating the entries to include the checkboxes
 - acting on the result.

 The Ajax.Autocompleter in scriptaculous requires you to return an
 unordered list for the 'drop-down', and there's nothing to stop you
 putting input elements inside the li's. If you still want to use
 the pick an entry from the list and it will be as if that had been
 typed in the text input box, you can do that - make sure the input
 elements are inside span class=informal, and the Autocompleter
 code will ignore them in generating the value to return.

 However, I'm guessing that that is not what you want, but rather for
 the user to proceed by ticking some of the boxes. In that case, I
 don't think Ajax.Autocompleter is going to be much use to you, and you
 might just as well use Ajax.Updater and do the rest yourself. You can
 possibly copy some code from Ajax.Autocompleter.

 The code you want (in very sketchy form) is something like

 observe($('textbox'), 'keypress', function() {
   Ajax.Updater('listdiv', ...
      {parameters: { partname: $F('textbox'), ...

 });

 And then your Ajax backend would match the 'partname', and deliver a
 list of

 liinput type=checkbox ... /inputTom/li

 or maybe just lines with br between

 You'll need more than this - probably want to put a delay on before
 sending, so as not to send until the user has stopped typing for a
 bit, and to handle ESC and things. You can copy some of these out of
 Ajax.Autocomplete.

 Colin

  Sig
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: autocomplete variant

2008-12-08 Thread macsig

Hello,
I have an issue with Ajax.updater.
Since I'm a prototype newbie I guess it is something easily solvable.

Basically I don't understand what I have to put as url.
In any example I can find on prototype website they show '/some_url'
without specifying its meaning.

Since my app is a Rails one I tried to create a partial (list_item)
with the list item and I passed it as a url but I get Couldn't find
Person with ID=list_item
If I remove the url parameter I get 
ActionController::MethodNotAllowed   Only get, put e delete requests
are allowed. even if I specify get as a method.


How can I fix it?

Any help is greatly appreciated.



Sig





On Dec 8, 11:47 am, macsig [EMAIL PROTECTED] wrote:
 Thanks Colin for your reply.

 Your second option sounds exactly what I need.
 I try to make it works.

 Have a nice day.

 On Dec 8, 3:49 am, ColinFine [EMAIL PROTECTED] wrote:

  On Dec 8, 3:05 am, macsig [EMAIL PROTECTED] wrote:

   Hello guys,
   I'm trying to implement a variant of the classic autocomplete but I
   can't make it works.
   Basically what I want is to show for each element that matches with
   the written text the element name and a checkbox (having the element
   id as a value).
   For instance, if my table contains:

   ID  | NAME
   1   | Tom
   2   | Timmy
   3   | John
   4   | Nick
   5   | Theodora

   When I digit 'T' on my textfield the div called friends should be
   populated with

   [] Tom
   [] Timmy
   [] Theodora

   Can someone help me out with this? Any help is welcome.

   thanks and have a nice day!

  There are several separate parts of this:
  - generating the entries to include the checkboxes
  - acting on the result.

  The Ajax.Autocompleter in scriptaculous requires you to return an
  unordered list for the 'drop-down', and there's nothing to stop you
  putting input elements inside the li's. If you still want to use
  the pick an entry from the list and it will be as if that had been
  typed in the text input box, you can do that - make sure the input
  elements are inside span class=informal, and the Autocompleter
  code will ignore them in generating the value to return.

  However, I'm guessing that that is not what you want, but rather for
  the user to proceed by ticking some of the boxes. In that case, I
  don't think Ajax.Autocompleter is going to be much use to you, and you
  might just as well use Ajax.Updater and do the rest yourself. You can
  possibly copy some code from Ajax.Autocompleter.

  The code you want (in very sketchy form) is something like

  observe($('textbox'), 'keypress', function() {
    Ajax.Updater('listdiv', ...
       {parameters: { partname: $F('textbox'), ...

  });

  And then your Ajax backend would match the 'partname', and deliver a
  list of

  liinput type=checkbox ... /inputTom/li

  or maybe just lines with br between

  You'll need more than this - probably want to put a delay on before
  sending, so as not to send until the user has stopped typing for a
  bit, and to handle ESC and things. You can copy some of these out of
  Ajax.Autocomplete.

  Colin

   Sig
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---