I was wondering if someone could help me with an autocomplete problem. I have the autocomplete div receiving a <UL> that looks like: <ul> <li>Name<br>Email</li> </ul> When the user hits enter and the value is filled into the text field it''s putting both the name and email in the field. I just want the name. Funny this works in Firefox but not IE. I wonder how this is a browser thing, since its looks like a parsing issue/setting in the library. Thanks for your time, Daniel
Hi Daniel, You have to wrap up anything you DON'T want to appear in the text box in a span tag with a class of 'informal'. For example: [ul] [li]John Smith<br />[span class="informal"]john@smith.com[/span][/li] [/ul] Regards, Cam On 12/6/05, Daniel Elmore <danielelmore@gmail.com> wrote:> I was wondering if someone could help me with an autocomplete problem. I > have the autocomplete div receiving a <UL> that looks like: > > <ul> > <li>Name<br>Email</li> > </ul> > > When the user hits enter and the value is filled into the text field > it's putting both the name and email in the field. I just want the name.<snip> _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Good! Thank you, that works! -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Cam McVey Sent: Tuesday, December 06, 2005 4:10 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] script.aculo.us AutoComplete Woes Hi Daniel, You have to wrap up anything you DON''T want to appear in the text box in a span tag with a class of ''informal''. For example: [ul] [li]John Smith<br />[span class="informal"]john-ktkBa0B26w0AvxtiuMwx3w@public.gmane.org[/span][/li] [/ul] Regards, Cam On 12/6/05, Daniel Elmore <danielelmore-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I was wondering if someone could help me with an autocomplete problem.I> have the autocomplete div receiving a <UL> that looks like: > > <ul> > <li>Name<br>Email</li> > </ul> > > When the user hits enter and the value is filled into the text field > it''s putting both the name and email in the field. I just want thename. <snip>
I have used the informal class on my own stuff (which works), but when I select an item, some whitespace is added before the selected text. It actually appears to be newlines that are being inserted into the textfield. Any ideas what may be causing this? Would this occur because of extra spacing in the markup I''m sending back from the server? I tried removing some, but it didn''t seem to have an affect. Thanks On 12/6/05, Daniel Elmore <danielelmore-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Good! Thank you, that works! > > > > -----Original Message----- > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Cam > McVey > Sent: Tuesday, December 06, 2005 4:10 AM > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: Re: [Rails-spinoffs] script.aculo.us AutoComplete Woes > > Hi Daniel, > > You have to wrap up anything you DON''T want to appear in the text box > in a span tag with a class of ''informal''. For example: > > [ul] > [li]John Smith<br />[span class="informal"]john-ktkBa0B26w0AvxtiuMwx3w@public.gmane.org[/span][/li] > [/ul] > > Regards, > Cam > > On 12/6/05, Daniel Elmore <danielelmore-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I was wondering if someone could help me with an autocomplete problem. > I > > have the autocomplete div receiving a <UL> that looks like: > > > > <ul> > > <li>Name<br>Email</li> > > </ul> > > > > When the user hits enter and the value is filled into the text field > > it''s putting both the name and email in the field. I just want the > name. > <snip> > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >
I had to modify the updateElement method to trim the spaces. Change this: this.element.value = value; To this: this.element.value = value.replace(/^\s*|\s*$/g,""); Not sure why that wouldn''t be there already. Daniel Elmore -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Andrew Kaspick Sent: Tuesday, May 23, 2006 3:14 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] script.aculo.us AutoComplete Woes I have used the informal class on my own stuff (which works), but when I select an item, some whitespace is added before the selected text. It actually appears to be newlines that are being inserted into the textfield. Any ideas what may be causing this? Would this occur because of extra spacing in the markup I''m sending back from the server? I tried removing some, but it didn''t seem to have an affect. Thanks On 12/6/05, Daniel Elmore <danielelmore-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Good! Thank you, that works! > > > > -----Original Message----- > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Cam > McVey > Sent: Tuesday, December 06, 2005 4:10 AM > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: Re: [Rails-spinoffs] script.aculo.us AutoComplete Woes > > Hi Daniel, > > You have to wrap up anything you DON''T want to appear in the text box > in a span tag with a class of ''informal''. For example: > > [ul] > [li]John Smith<br />[span class="informal"]john-ktkBa0B26w0AvxtiuMwx3w@public.gmane.org[/span][/li] > [/ul] > > Regards, > Cam > > On 12/6/05, Daniel Elmore <danielelmore-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I was wondering if someone could help me with an autocomplete problem. > I > > have the autocomplete div receiving a <UL> that looks like: > > > > <ul> > > <li>Name<br>Email</li> > > </ul> > > > > When the user hits enter and the value is filled into the text field > > it''s putting both the name and email in the field. I just want the > name. > <snip> > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Yeah, I was looking into that too, but thought that I must be doing something wrong since the customized autocomplete demo on the scriptaculous site seems to trim the space somehow. Thanks though, I''ll try making the change you suggested. On 5/23/06, Daniel Elmore <danielelmore-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I had to modify the updateElement method to trim the spaces. > > Change this: > this.element.value = value; > > To this: > this.element.value = value.replace(/^\s*|\s*$/g,""); > > > Not sure why that wouldn''t be there already. > > Daniel Elmore > > > -----Original Message----- > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Andrew > Kaspick > Sent: Tuesday, May 23, 2006 3:14 PM > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: Re: [Rails-spinoffs] script.aculo.us AutoComplete Woes > > I have used the informal class on my own stuff (which works), but when > I select an item, some whitespace is added before the selected text. > It actually appears to be newlines that are being inserted into the > textfield. > > Any ideas what may be causing this? Would this occur because of extra > spacing in the markup I''m sending back from the server? I tried > removing some, but it didn''t seem to have an affect. > > Thanks > > On 12/6/05, Daniel Elmore <danielelmore-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Good! Thank you, that works! > > > > > > > > -----Original Message----- > > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Cam > > McVey > > Sent: Tuesday, December 06, 2005 4:10 AM > > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > Subject: Re: [Rails-spinoffs] script.aculo.us AutoComplete Woes > > > > Hi Daniel, > > > > You have to wrap up anything you DON''T want to appear in the text box > > in a span tag with a class of ''informal''. For example: > > > > [ul] > > [li]John Smith<br />[span class="informal"]john-ktkBa0B26w0AvxtiuMwx3w@public.gmane.org[/span][/li] > > [/ul] > > > > Regards, > > Cam > > > > On 12/6/05, Daniel Elmore <danielelmore-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I was wondering if someone could help me with an autocomplete problem. > > I > > > have the autocomplete div receiving a <UL> that looks like: > > > > > > <ul> > > > <li>Name<br>Email</li> > > > </ul> > > > > > > When the user hits enter and the value is filled into the text field > > > it''s putting both the name and email in the field. I just want the > > name. > > <snip> > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >
If you look at the ajax response content on the demo site, you won''t find any spaces in the markup. This is obviously harder to avoid if you''re using some middleware to build your response data. Daniel Elmore -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Andrew Kaspick Sent: Tuesday, May 23, 2006 3:36 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] script.aculo.us AutoComplete Woes Yeah, I was looking into that too, but thought that I must be doing something wrong since the customized autocomplete demo on the scriptaculous site seems to trim the space somehow. Thanks though, I''ll try making the change you suggested. On 5/23/06, Daniel Elmore <danielelmore-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I had to modify the updateElement method to trim the spaces. > > Change this: > this.element.value = value; > > To this: > this.element.value = value.replace(/^\s*|\s*$/g,""); > > > Not sure why that wouldn''t be there already. > > Daniel Elmore > > > -----Original Message----- > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Andrew > Kaspick > Sent: Tuesday, May 23, 2006 3:14 PM > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: Re: [Rails-spinoffs] script.aculo.us AutoComplete Woes > > I have used the informal class on my own stuff (which works), but when > I select an item, some whitespace is added before the selected text. > It actually appears to be newlines that are being inserted into the > textfield. > > Any ideas what may be causing this? Would this occur because of extra > spacing in the markup I''m sending back from the server? I tried > removing some, but it didn''t seem to have an affect. > > Thanks > > On 12/6/05, Daniel Elmore <danielelmore-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Good! Thank you, that works! > > > > > > > > -----Original Message----- > > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Cam > > McVey > > Sent: Tuesday, December 06, 2005 4:10 AM > > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > Subject: Re: [Rails-spinoffs] script.aculo.us AutoComplete Woes > > > > Hi Daniel, > > > > You have to wrap up anything you DON''T want to appear in the text box > > in a span tag with a class of ''informal''. For example: > > > > [ul] > > [li]John Smith<br />[span class="informal"]john-ktkBa0B26w0AvxtiuMwx3w@public.gmane.org[/span][/li] > > [/ul] > > > > Regards, > > Cam > > > > On 12/6/05, Daniel Elmore <danielelmore-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I was wondering if someone could help me with an autocomplete problem. > > I > > > have the autocomplete div receiving a <UL> that looks like: > > > > > > <ul> > > > <li>Name<br>Email</li> > > > </ul> > > > > > > When the user hits enter and the value is filled into the text field > > > it''s putting both the name and email in the field. I just want the > > name. > > <snip> > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
For now, I''ve used the afterUpdateElement callback to strip the whitespace using the code you provided and it works great now. Now I don''t need to migrate the change to any future scriptaculous releases. Thanks for the pointers. On 5/23/06, Daniel Elmore <danielelmore-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> If you look at the ajax response content on the demo site, you won''t find > any spaces in the markup. This is obviously harder to avoid if you''re using > some middleware to build your response data. > > Daniel Elmore > > > -----Original Message----- > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Andrew > Kaspick > Sent: Tuesday, May 23, 2006 3:36 PM > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: Re: [Rails-spinoffs] script.aculo.us AutoComplete Woes > > Yeah, I was looking into that too, but thought that I must be doing > something wrong since the customized autocomplete demo on the > scriptaculous site seems to trim the space somehow. > > Thanks though, I''ll try making the change you suggested. > > On 5/23/06, Daniel Elmore <danielelmore-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I had to modify the updateElement method to trim the spaces. > > > > Change this: > > this.element.value = value; > > > > To this: > > this.element.value = value.replace(/^\s*|\s*$/g,""); > > > > > > Not sure why that wouldn''t be there already. > > > > Daniel Elmore > > > > > > -----Original Message----- > > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Andrew > > Kaspick > > Sent: Tuesday, May 23, 2006 3:14 PM > > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > Subject: Re: [Rails-spinoffs] script.aculo.us AutoComplete Woes > > > > I have used the informal class on my own stuff (which works), but when > > I select an item, some whitespace is added before the selected text. > > It actually appears to be newlines that are being inserted into the > > textfield. > > > > Any ideas what may be causing this? Would this occur because of extra > > spacing in the markup I''m sending back from the server? I tried > > removing some, but it didn''t seem to have an affect. > > > > Thanks > > > > On 12/6/05, Daniel Elmore <danielelmore-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Good! Thank you, that works! > > > > > > > > > > > > -----Original Message----- > > > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Cam > > > McVey > > > Sent: Tuesday, December 06, 2005 4:10 AM > > > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > Subject: Re: [Rails-spinoffs] script.aculo.us AutoComplete Woes > > > > > > Hi Daniel, > > > > > > You have to wrap up anything you DON''T want to appear in the text box > > > in a span tag with a class of ''informal''. For example: > > > > > > [ul] > > > [li]John Smith<br />[span class="informal"]john-ktkBa0B26w0AvxtiuMwx3w@public.gmane.org[/span][/li] > > > [/ul] > > > > > > Regards, > > > Cam > > > > > > On 12/6/05, Daniel Elmore <danielelmore-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I was wondering if someone could help me with an autocomplete problem. > > > I > > > > have the autocomplete div receiving a <UL> that looks like: > > > > > > > > <ul> > > > > <li>Name<br>Email</li> > > > > </ul> > > > > > > > > When the user hits enter and the value is filled into the text field > > > > it''s putting both the name and email in the field. I just want the > > > name. > > > <snip> > > > > > > _______________________________________________ > > > Rails-spinoffs mailing list > > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >
Good idea, can you show me how you did that? Daniel Elmore -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Andrew Kaspick Sent: Tuesday, May 23, 2006 4:00 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] script.aculo.us AutoComplete Woes For now, I''ve used the afterUpdateElement callback to strip the whitespace using the code you provided and it works great now. Now I don''t need to migrate the change to any future scriptaculous releases. Thanks for the pointers. On 5/23/06, Daniel Elmore <danielelmore-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> If you look at the ajax response content on the demo site, you won''t find > any spaces in the markup. This is obviously harder to avoid if you''reusing> some middleware to build your response data. > > Daniel Elmore > > > -----Original Message----- > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Andrew > Kaspick > Sent: Tuesday, May 23, 2006 3:36 PM > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: Re: [Rails-spinoffs] script.aculo.us AutoComplete Woes > > Yeah, I was looking into that too, but thought that I must be doing > something wrong since the customized autocomplete demo on the > scriptaculous site seems to trim the space somehow. > > Thanks though, I''ll try making the change you suggested. > > On 5/23/06, Daniel Elmore <danielelmore-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I had to modify the updateElement method to trim the spaces. > > > > Change this: > > this.element.value = value; > > > > To this: > > this.element.value = value.replace(/^\s*|\s*$/g,""); > > > > > > Not sure why that wouldn''t be there already. > > > > Daniel Elmore > > > > > > -----Original Message----- > > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf OfAndrew> > Kaspick > > Sent: Tuesday, May 23, 2006 3:14 PM > > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > Subject: Re: [Rails-spinoffs] script.aculo.us AutoComplete Woes > > > > I have used the informal class on my own stuff (which works), but when > > I select an item, some whitespace is added before the selected text. > > It actually appears to be newlines that are being inserted into the > > textfield. > > > > Any ideas what may be causing this? Would this occur because of extra > > spacing in the markup I''m sending back from the server? I tried > > removing some, but it didn''t seem to have an affect. > > > > Thanks > > > > On 12/6/05, Daniel Elmore <danielelmore-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Good! Thank you, that works! > > > > > > > > > > > > -----Original Message----- > > > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Cam > > > McVey > > > Sent: Tuesday, December 06, 2005 4:10 AM > > > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > Subject: Re: [Rails-spinoffs] script.aculo.us AutoComplete Woes > > > > > > Hi Daniel, > > > > > > You have to wrap up anything you DON''T want to appear in the text box > > > in a span tag with a class of ''informal''. For example: > > > > > > [ul] > > > [li]John Smith<br />[spanclass="informal"]john-ktkBa0B26w0AvxtiuMwx3w@public.gmane.org[/span][/li]> > > [/ul] > > > > > > Regards, > > > Cam > > > > > > On 12/6/05, Daniel Elmore <danielelmore-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I was wondering if someone could help me with an autocompleteproblem.> > > I > > > > have the autocomplete div receiving a <UL> that looks like: > > > > > > > > <ul> > > > > <li>Name<br>Email</li> > > > > </ul> > > > > > > > > When the user hits enter and the value is filled into the text field > > > > it''s putting both the name and email in the field. I just want the > > > name. > > > <snip> > > > > > > _______________________________________________ > > > Rails-spinoffs mailing list > > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Sure, this is my (modified) code using one of the ruby helpers, but it''s pretty straight forward to convert to JS only... text_field_with_auto_complete :search, :data, {}, :after_update_element => <<-JS function (field, element) { field.value = field.value.replace(/^\s*|\s*$/g, '''') } JS "field" is the text input element and "element" here is the selected LI. If you put the code between quotes then just escape the various pieces of the regex and you''re good to go. Andrew On 5/23/06, Daniel Elmore <danielelmore-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Good idea, can you show me how you did that? > > Daniel Elmore > > -----Original Message----- > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Andrew > Kaspick > Sent: Tuesday, May 23, 2006 4:00 PM > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: Re: [Rails-spinoffs] script.aculo.us AutoComplete Woes > > For now, I''ve used the afterUpdateElement callback to strip the > whitespace using the code you provided and it works great now. > > Now I don''t need to migrate the change to any future scriptaculous releases. > > Thanks for the pointers. > > On 5/23/06, Daniel Elmore <danielelmore-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > If you look at the ajax response content on the demo site, you won''t find > > any spaces in the markup. This is obviously harder to avoid if you''re > using > > some middleware to build your response data. > > > > Daniel Elmore > > > > > > -----Original Message----- > > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Andrew > > Kaspick > > Sent: Tuesday, May 23, 2006 3:36 PM > > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > Subject: Re: [Rails-spinoffs] script.aculo.us AutoComplete Woes > > > > Yeah, I was looking into that too, but thought that I must be doing > > something wrong since the customized autocomplete demo on the > > scriptaculous site seems to trim the space somehow. > > > > Thanks though, I''ll try making the change you suggested. > > > > On 5/23/06, Daniel Elmore <danielelmore-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I had to modify the updateElement method to trim the spaces. > > > > > > Change this: > > > this.element.value = value; > > > > > > To this: > > > this.element.value = value.replace(/^\s*|\s*$/g,""); > > > > > > > > > Not sure why that wouldn''t be there already. > > > > > > Daniel Elmore > > > > > > > > > -----Original Message----- > > > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of > Andrew > > > Kaspick > > > Sent: Tuesday, May 23, 2006 3:14 PM > > > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > Subject: Re: [Rails-spinoffs] script.aculo.us AutoComplete Woes > > > > > > I have used the informal class on my own stuff (which works), but when > > > I select an item, some whitespace is added before the selected text. > > > It actually appears to be newlines that are being inserted into the > > > textfield. > > > > > > Any ideas what may be causing this? Would this occur because of extra > > > spacing in the markup I''m sending back from the server? I tried > > > removing some, but it didn''t seem to have an affect. > > > > > > Thanks > > > > > > On 12/6/05, Daniel Elmore <danielelmore-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Good! Thank you, that works! > > > > > > > > > > > > > > > > -----Original Message----- > > > > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Cam > > > > McVey > > > > Sent: Tuesday, December 06, 2005 4:10 AM > > > > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > > Subject: Re: [Rails-spinoffs] script.aculo.us AutoComplete Woes > > > > > > > > Hi Daniel, > > > > > > > > You have to wrap up anything you DON''T want to appear in the text box > > > > in a span tag with a class of ''informal''. For example: > > > > > > > > [ul] > > > > [li]John Smith<br />[span > class="informal"]john-ktkBa0B26w0AvxtiuMwx3w@public.gmane.org[/span][/li] > > > > [/ul] > > > > > > > > Regards, > > > > Cam > > > > > > > > On 12/6/05, Daniel Elmore <danielelmore-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I was wondering if someone could help me with an autocomplete > problem. > > > > I > > > > > have the autocomplete div receiving a <UL> that looks like: > > > > > > > > > > <ul> > > > > > <li>Name<br>Email</li> > > > > > </ul> > > > > > > > > > > When the user hits enter and the value is filled into the text field > > > > > it''s putting both the name and email in the field. I just want the > > > > name. > > > > <snip> > > > > > > > > _______________________________________________ > > > > Rails-spinoffs mailing list > > > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > _______________________________________________ > > > Rails-spinoffs mailing list > > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > _______________________________________________ > > > Rails-spinoffs mailing list > > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >