Hi everyone, I need to trigger a Rails action after the autocompletion is completed (when the user has selected an option). From the scriptaculous doc, I figured out ''afterUpdateElement'' is the place to be but I wonder if/how and where I can hook my javascript code to this event in Rails code (I''d like to keep using the helper, if possible)? I tried passing many variations of :after_update_element=> "alert(''after_update_element action'')" in _text_field_with_auto_complete_ and _auto_complete_field_ to no avail. Any hint? TIA Alain
Alain Ravet
2006-Apr-02 10:12 UTC
(SOLVED) Re: autocompletion: hooking ''afterUpdateElement'' in Rails
There''s already a tiny patch in the waiting list that solves that very problem: http://dev.rubyonrails.org/ticket/3691 [PATCH] Add frequency and afterupdateelement option to text_field_with_auto_complete It justs adds 2 lines in the _auto_complete_field_ method (java_script_macros_helper.rb) js_options[:frequency] = "#{options[:frequency]}" if options[:frequency] js_options[:afterUpdateElement] = "function(element,value) { return #{options[:after_update_element]}(element,value); }" if options[:after_update_element] Alain
Bob Silva
2006-Apr-02 13:19 UTC
RE: (SOLVED) Re: autocompletion: hooking''afterUpdateElement'' in Rails
I lobbied to get this included in 1.1. Not sure why it wasn''t accepted. Bob Silva http://www.railtie.net/> -----Original Message----- > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs- > bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Alain Ravet > Sent: Sunday, April 02, 2006 3:12 AM > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: [Rails-spinoffs] (SOLVED) Re: autocompletion: > hooking''afterUpdateElement'' in Rails > > There''s already a tiny patch in the waiting list that solves that very > problem: > > http://dev.rubyonrails.org/ticket/3691 > [PATCH] Add frequency and afterupdateelement option to > text_field_with_auto_complete > > It justs adds 2 lines in the _auto_complete_field_ method > (java_script_macros_helper.rb) > js_options[:frequency] = "#{options[:frequency]}" if > options[:frequency] > js_options[:afterUpdateElement] = "function(element,value) { > return #{options[:after_update_element]}(element,value); }" if > options[:after_update_element] > > > > Alain > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Thomas Fuchs
2006-Apr-02 14:05 UTC
Re: (SOLVED) Re: autocompletion: hooking''afterUpdateElement'' in Rails
I''ve added this to the rails trunk, but slightly altered the proposed patch, (see the comment on #3691). Here''s the changeset: http://dev.rubyonrails.org/changeset/4131 -Thomas Am 02.04.2006 um 15:19 schrieb Bob Silva:> I lobbied to get this included in 1.1. Not sure why it wasn''t > accepted. > > Bob Silva > http://www.railtie.net/ > >> -----Original Message----- >> From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails- >> spinoffs- >> bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Alain Ravet >> Sent: Sunday, April 02, 2006 3:12 AM >> To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> Subject: [Rails-spinoffs] (SOLVED) Re: autocompletion: >> hooking''afterUpdateElement'' in Rails >> >> There''s already a tiny patch in the waiting list that solves that >> very >> problem: >> >> http://dev.rubyonrails.org/ticket/3691 >> [PATCH] Add frequency and afterupdateelement option to >> text_field_with_auto_complete >> >> It justs adds 2 lines in the _auto_complete_field_ method >> (java_script_macros_helper.rb) >> js_options[:frequency] = "#{options[:frequency]}" if >> options[:frequency] >> js_options[:afterUpdateElement] = "function(element,value) { >> return #{options[:after_update_element]}(element,value); }" if >> options[:after_update_element] >> >> >> >> Alain >> >> _______________________________________________ >> 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-- Thomas Fuchs wollzelle http://www.wollzelle.com http://www.fluxiom.com :: online digital asset management http://script.aculo.us :: Web 2.0 JavaScript http://mir.aculo.us :: Where no web developer has gone before
Alain Ravet
2006-Apr-05 15:59 UTC
Re: (SOLVED) Re: autocompletion: hooking''afterUpdateElement'' in Rails
> I''ve added this to the rails trunk, but slightly altered the proposed> patch, (see the comment on #3691). It must be obvious by I can''t find my way the new syntax. With the "old" syntax (patch 3691), I had written code like this : <%= text_field_with_auto_complete :city, :name, {}, :after_update_element => remote_function( :url => { :action => :update_city_zips }, :with =>"''selected_city_name=''+element.value") %> How should it be rewritten for the new syntax? TIA Alain
Alain Ravet
2006-Apr-06 20:18 UTC
Re: (SOLVED) Re: autocompletion: hooking''afterUpdateElement'' in Rails
Anybody? How does one call a remote_function with after_update_element ? Alain> It must be obvious by I can''t find my way the new syntax. > With the "old" syntax (patch 3691), I had written code like this : > > <%= text_field_with_auto_complete :city, :name, {}, > :after_update_element => remote_function( > :url => { :action => :update_city_zips }, > :with =>"''selected_city_name=''+element.value") > %> > > How should it be rewritten for the new syntax?
Thomas Fuchs
2006-Apr-07 08:00 UTC
Re: Re: (SOLVED) Re: autocompletion: hooking''afterUpdateElement'' in Rails
This should work (haven''t tested it): :after_update_element => "function(element,value){" + remote_function(:url => { :action => :update_city_zips }, :with =>"''selected_city_name=''+element.value") + "}" If it doesn''t, drop by in #prototype on freenode.net (today!) so we can have a look. -Thomas Am 06.04.2006 um 22:18 schrieb Alain Ravet:> Anybody? > > How does one call a remote_function with after_update_element ? > > > Alain > > >> It must be obvious by I can''t find my way the new syntax. >> With the "old" syntax (patch 3691), I had written code like this : >> <%= text_field_with_auto_complete :city, :name, {}, >> :after_update_element => remote_function( >> :url => { :action => :update_city_zips }, >> :with =>"''selected_city_name=''+element.value") >> %> >> How should it be rewritten for the new syntax? > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs-- Thomas Fuchs wollzelle http://www.wollzelle.com http://www.fluxiom.com :: online digital asset management http://script.aculo.us :: Web 2.0 JavaScript http://mir.aculo.us :: Where no web developer has gone before
Thomas > This should work (haven''t tested it): It worked fine. Many thanks. Alain
i took the prototype and all the scriptaculous .js files and combined them into one, then i ran it through the compressor at http://www.creativyst.com/Prod/3/ it was able to compress it down about 77%. what i am wondering is, is this safe to use? i am just looking to chop down the 152kb of all the .js combined.
I just tried the compressor, it compressed the files _to_ 77% of their original size. I compared this to GZIP by compressing prototype.js, 47603 bytes, down to 10632 bytes, so that might be a better choice. - David Am 07.04.2006 um 21:52 schrieb Louis Walch:> i took the prototype and all the scriptaculous .js files and > combined them > into one, then i ran it through the compressor at > http://www.creativyst.com/Prod/3/ > > it was able to compress it down about 77%. what i am wondering is, > is this > safe to use? i am just looking to chop down the 152kb of all the .js > combined. > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >
Thanks for the link, I just tried it out. It seems to take out whitespaces and comments, but is not "intelligent" Is anybody aware of a JS compressor which ofuscates by replacing variables with short-named versions (just one letter) ? On 4/8/06, David Zülke <dz-c16oUwy5/3O+XT7JhA+gdA@public.gmane.org> wrote:> > I just tried the compressor, it compressed the files _to_ 77% of > their original size. I compared this to GZIP by compressing > prototype.js, 47603 bytes, down to 10632 bytes, so that might be a > better choice. > > - David > > > Am 07.04.2006 um 21:52 schrieb Louis Walch: > > > i took the prototype and all the scriptaculous .js files and > > combined them > > into one, then i ran it through the compressor at > > http://www.creativyst.com/Prod/3/ > > > > it was able to compress it down about 77%. what i am wondering is, > > is this > > safe to use? i am just looking to chop down the 152kb of all the .js > > combined. > > _______________________________________________ > > 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 >-- Roberto Saccon - http://rsaccon.com _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
There are a number. PAcker from codethat.com is one commercial one. On Apr 8, 2006, at 6:37 AM, Roberto Saccon wrote:> Thanks for the link, I just tried it out. It seems to take out > whitespaces and comments, but is not "intelligent" > > Is anybody aware of a JS compressor which ofuscates by replacing > variables with short-named versions (just one letter) ? > > On 4/8/06, David Zülke <dz-c16oUwy5/3O+XT7JhA+gdA@public.gmane.org> wrote: > I just tried the compressor, it compressed the files _to_ 77% of > their original size. I compared this to GZIP by compressing > prototype.js, 47603 bytes, down to 10632 bytes, so that might be a > better choice. > > - David > > > Am 07.04.2006 um 21:52 schrieb Louis Walch: > > > i took the prototype and all the scriptaculous .js files and > > combined them > > into one, then i ran it through the compressor at > > http://www.creativyst.com/Prod/3/ > > > > it was able to compress it down about 77%. what i am wondering is, > > is this > > safe to use? i am just looking to chop down the 152kb of all the .js > > combined. > > _______________________________________________ > > 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 > > > > -- > Roberto Saccon - http://rsaccon.com > _______________________________________________ > 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
On Sat, Apr 08, 2006 at 02:06:29PM +0200, David Zülke wrote:> I just tried the compressor, it compressed the files _to_ 77% of > their original size. I compared this to GZIP by compressing > prototype.js, 47603 bytes, down to 10632 bytes, so that might be a > better choice.Is compressing to save time over the wire? I get that same compression using mod_gzip (or gzip compression & caching in the application). -- Bill Moseley moseley-kv6DSSSScSo@public.gmane.org
One word: gzip This provides: 1. Much better compression ratios 2. It doesn''t mess with the JavaScript 3. You still get decent messages if JavaScript errors should happen 4. It''s completely transparent to both your application and the browser Implementation depends on the webserver, of course. Apache has mod_gzip and mod_deflate, and lighttpd comes with mod_compress. -Thomas Am 07.04.2006 um 21:52 schrieb Louis Walch:> i took the prototype and all the scriptaculous .js files and > combined them > into one, then i ran it through the compressor at > http://www.creativyst.com/Prod/3/ > > it was able to compress it down about 77%. what i am wondering is, > is this > safe to use? i am just looking to chop down the 152kb of all the .js > combined. > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs