[Proto-Scripty] Re: autocomplete variant

2008-12-09 Thread ColinFine



On Dec 8, 9:30 pm, macsig <[EMAIL PROTECTED]> wrote:
> 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.
>
The url is entirely up to you. It is the URL of the script that you
write to be the Ajax backend: you can call it what you like, and put
it where you like (though it introduces many problems if it isn't on
the same domain as the script it's being called from).

> 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.

I don't know Rails, but if it's anything like symfony, a partial isn't
enough: it needs to be its own page, which will parse the arguments
from the query string, generate the output, and send it with the
proper headers. It could be bare text, XML, HTML or it could be empty
and return the data in an X-JSON heaader. But if you're going to use
Ajax.Updater, you need to return an HTML fragment (not a whole HTML
page). In any case, though, it needs to have suitable HTTP headers.
I'm guessing that Rails has a way of creating a page which only
returns the headers and text you want.

Colin

--~--~-~--~~~---~--~~
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  elements inside the '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 
> > elements are inside , 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
>
> > Tom
>
> > or maybe just lines with  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

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  elements inside the '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 
> elements are inside , 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
>
> Tom
>
> or maybe just lines with  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 ColinFine



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  elements inside the '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 
elements are inside , 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

Tom

or maybe just lines with  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
-~--~~~~--~~--~--~---