Hi,
Using the autocomplete gives me some strange bug in firefox.
After I select an entry from a list the text in the <input> box changes
to the text from the list item, but it also adds extra empty lines
around it. So the value of the textbox becomes something like:
-empty line
-empty line
-empty line
-empty line
email
-empty line
-empty line
-empty line
In IE it looks alright. I used
http://script.aculo.us/demos/ajax/autocompleter_customized as a starting
point. That URL works fine in IE and FF.
Here''s my code
#_users.rhtml
<%= text_field_with_auto_complete :user, :email, {}, :skip_style => true
%>
#user controller
def auto_complete_for_user_email
value = params[:user][:email]
@users = User.find(:all,
:conditions => [ ''email LIKE ?'', value.downcase +
''%'' ],
:order => ''email ASC'',
:limit => 8)
render :partial => ''users''
end
You''re probably outputting those empty lines. The Autocompleter takes the whole text content of the returned LI elements when selecting an entry, which includes linebreaks. Try not outputting linebreaks. If you have further problems, post the contents of your _user.rhtml partial. Thomas Am 24.10.2005 um 13:07 schrieb Jeroen Houben:> Hi, > > Using the autocomplete gives me some strange bug in firefox. > After I select an entry from a list the text in the <input> box > changes to the text from the list item, but it also adds extra > empty lines around it. So the value of the textbox becomes > something like: > > -empty line > -empty line > -empty line > -empty line > email > -empty line > -empty line > -empty line > > In IE it looks alright. I used http://script.aculo.us/demos/ajax/ > autocompleter_customized as a starting point. That URL works fine > in IE and FF. > > Here''s my code > > #_users.rhtml > <%= text_field_with_auto_complete :user, :email, {}, :skip_style => > true %> > > #user controller > def auto_complete_for_user_email > value = params[:user][:email] > > @users = User.find(:all, > :conditions => [ ''email LIKE ?'', value.downcase + ''%'' ], > :order => ''email ASC'', > :limit => 8) > render :partial => ''users'' > end > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Thomas Fuchs wrote:> You''re probably outputting those empty lines. The Autocompleter takes > the whole text content of the returned > LI elements when selecting an entry, which includes linebreaks. > > Try not outputting linebreaks.Okay that seems to help, thank you (should have read the FAQ - looking at it now) Is there some kind of filter that strips white space from a chunk of rhtml? In PHP/Smarty I often use a block and everything inside that block will on one line, like {oneliner} m u l t i l i n e {/oneliner} would out put as "multiline" Thanks! Jeroen
Jeroen Houben wrote:> Thomas Fuchs wrote: > >> You''re probably outputting those empty lines. The Autocompleter takes >> the whole text content of the returned >> LI elements when selecting an entry, which includes linebreaks. >> >> Try not outputting linebreaks. > > > Okay that seems to help, thank you (should have read the FAQ - looking > at it now) > > Is there some kind of filter that strips white space from a chunk of rhtml?I guess I can simply define an after_filter for this.. Jeroen
you can try using <%= ... -> mind the "-" before the closing
>. this
should prevent the linebreak normally outputted by <%= ... >.
you can also use an after_filter for your action that does this
(untested, just from my head):
after_filter :remove_linebreaks, :only
=> :auto_complete_for_user_email
def remove_linebreaks
response.body = response.body.to_s.gsub(/\n/,'''')
end
Thomas
Am 24.10.2005 um 13:46 schrieb Jeroen Houben:
> Thomas Fuchs wrote:
>
>> You''re probably outputting those empty lines. The
Autocompleter
>> takes the whole text content of the returned
>> LI elements when selecting an entry, which includes linebreaks.
>> Try not outputting linebreaks.
>>
>
> Okay that seems to help, thank you (should have read the FAQ -
> looking at it now)
>
> Is there some kind of filter that strips white space from a chunk
> of rhtml?
>
> In PHP/Smarty I often use a block and everything inside that block
> will on one line, like
>
> {oneliner}
> m
> u
> l
> t
> i
> l
> i
> n
> e
> {/oneliner}
>
> would out put as "multiline"
>
> Thanks!
>
> Jeroen
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
Thomas Fuchs wrote:> you can try using <%= ... -> mind the "-" before the closing >. this > should prevent the linebreak normally outputted by <%= ... >. > > you can also use an after_filter for your action that does this > (untested, just from my head): > > after_filter :remove_linebreaks, :only => :auto_complete_for_user_email > > def remove_linebreaks > response.body = response.body.to_s.gsub(/\n/,'''') > endIf there are no tabs on the rhtml then this works: class WhiteSpaceFilter def self.filter(controller) controller.response.body.gsub!(/\n/, '''') controller.response.body.gsub!(/\r/, '''') end end I guess you can filter out tabs as well. A bit clumsy to use the gsub twice, I suppose there''s a way to do it in one go but my Regex skills aren''t great... Jeroen