Good day. I have searched on the net and through the archives to now avail as of yet. I have a text_field_with_auto_complete that searches for company names. These company names obviously can have an ''&'' in the name of the company (example Barnes & Nobel). The auto complete works beautifully. However, the problem arises when I pass the name of the company to the controller to use in searching the customers for the other information in the database relevant to the customer. Error result ==> :company_name => "Barnes ", :Nobel => "" Expected/Desired result ==> :company_name => "Barnes & Nobel" Code in view: <%= text_field_with_auto_complete :supplier, :company_name, { :size => "45", :value => @supplier.company_name }, :after_update_element => "function(element,value){" + remote_function( :url => { :action => :get_supplier_address }, :with => "''supplier=''+escape($F(''supplier_company_name''))") + "}" %> controller: def auto_complete_for_supplier_company_name @suppliers = Supplier.find(:all, :conditions => ["company_name LIKE ?", params[:supplier][:company_name] + ''%'']) if @suppliers.length == 0 flash_warning(:now, ''No Suppliers found with company name starting with '' + params[:supplier][:company_name].to_s + ''!'') render :partial => ''no_values'' else render :partial => "supplier_names", :layout => false end end Thoughts on how to get the expected value here? -- ~d "Right is right, even if everyone is against it, and wrong is wrong, even if everyone is for it." -- William Penn www.razorpress.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060807/4e82f05c/attachment.html
Damon Hill
2006-Aug-08 12:31 UTC
[Rails] Re: Escape ''&'' in text_field_with_auto_complete
So, does this mean no one has this situation at all, or that everyone considers it so trivial that they don''t bother responding to the question? I would have hoped that someone could have shed some light on the problem by now. Off to waste more time digging through the web. Thanks, On 8/7/06, Damon Hill <damon@nwark.com> wrote:> > Good day. > > I have searched on the net and through the archives to now avail as of > yet. > I have a text_field_with_auto_complete that searches for company names. > These company names obviously can have an ''&'' in the name of the company > (example Barnes & Nobel). > The auto complete works beautifully. > > However, the problem arises when I pass the name of the company to the > controller to use in searching the customers for the other information in > the database relevant to the customer. > > Error result ==> :company_name => "Barnes ", :Nobel => "" > Expected/Desired result ==> :company_name => "Barnes & Nobel" > > Code in view: > > <%= text_field_with_auto_complete :supplier, :company_name, { :size => > "45", :value => @ supplier.company_name }, :after_update_element => > "function(element,value){" + > remote_function( :url => { :action => :get_supplier_address > }, :with => "''supplier=''+escape($F(''supplier_company_name''))") + "}" %> > > controller: > > def auto_complete_for_supplier_company_name > @suppliers = Supplier.find(:all, :conditions => ["company_name LIKE > ?", params[:supplier][:company_name] + ''%'']) > if @suppliers.length == 0 > flash_warning(:now, ''No Suppliers found with company name > starting with '' + params[:supplier][:company_name].to_s + ''!'') > render :partial => ''no_values'' > else > render :partial => "supplier_names", :layout => false > end > end > > Thoughts on how to get the expected value here? > > -- > ~d > "Right is right, even if everyone is against it, and wrong is wrong, even > if everyone is for it." -- William Penn > www.razorpress.com >-- ~d "Right is right, even if everyone is against it, and wrong is wronge, even if everyone is for it." -- William Penn www.razorpress.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060808/7d67fb9b/attachment.html
Seemingly Similar Threads
- scriptaculous - auto complete textbox with a drop down
- Re:(RESOLVED, KIND OF) auto complete and after update element
- auto complete and after update element
- R 1.7.0 (Windows) Crashes After using "Install Package from Cran option" within
- trouble-with-capybara-and-rspec-on-a-new-model-spec