Ticket #8771: observe_field_examples.diff
| File observe_field_examples.diff, 2.4 kB (added by andrej, 1 year ago) |
|---|
-
actionpack/lib/action_view/helpers/prototype_helper.rb
old new 269 269 # Required +options+ are either of: 270 270 # <tt>:url</tt>:: +url_for+-style options for the action to call 271 271 # when the field has changed. 272 # 273 # Example 274 # 275 # :url => {:controller => 'graph', :action => 'new'} 272 276 # <tt>:function</tt>:: Instead of making a remote call to a URL, you 273 277 # can specify a function to be called instead. 274 278 # … … 293 297 # :with => "'my_custom_key=' + value" 294 298 # :with => "'person[name]=' + prompt('New name')" 295 299 # :with => "Form.Element.serialize('other-field')" 300 # :with => "'id=' + escape(value)" 296 301 # 297 302 # Finally 298 303 # :with => 'name' … … 307 312 # 308 313 # Additionally, you may specify any of the options documented in 309 314 # link_to_remote. 315 # 316 # A typical application updates a <div id='graph'> with the result of an AJAX 317 # call and also shows a spinner in <div id='spinner'> while loading. 318 # 319 # Example: 320 # <%= observe_field('id', 321 # :update => "graph", 322 # :url => {:controller => 'graph', :action => 'new'}, 323 # :with => "'id=' + escape(value)", 324 # :loading => "Element.hide(\"graph\");Element.show(\"spinner\");", 325 # :complete => "Element.hide(\"spinner\");Element.show(\"graph\");") %> 326 # 327 # or alternatively use the <tt>Element.toggle()</tt> javascript 328 # 329 # <%= observe_field('id', 330 # :update => "graph", 331 # :url => {:controller => 'graph', :action => 'new'}, 332 # :with => "'id=' + escape(value)", 333 # :loading => "Element.toggle(\"graph\");Element.toggle(\"spinner\");", 334 # :complete => "Element.toggle(\"spinner\");Element.toggle(\"graph\");") %> 310 335 def observe_field(field_id, options = {}) 311 336 if options[:frequency] && options[:frequency] > 0 312 337 build_observer('Form.Element.Observer', field_id, options)