Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #5798: prototype_variable_name.diff

File prototype_variable_name.diff, 1.8 kB (added by andrew.grim@planetargon.com, 2 years ago)

patch diff

  • actionpack/test/template/prototype_helper_test.rb

    old new  
    5757      periodically_call_remote(:update => "schremser_bier", :url => { :action => "mehr_bier" }) 
    5858  end 
    5959   
     60  def test_periodically_call_remote_with_variable_name 
     61    assert_dom_equal %(<script type="text/javascript">\n//<![CDATA[\nvar pe = new PeriodicalExecuter(function() {new Ajax.Updater('schremser_bier', 'http://www.example.com/mehr_bier', {asynchronous:true, evalScripts:true})}, 10)\n//]]>\n</script>), 
     62      periodically_call_remote(:update => "schremser_bier", :url => { :action => "mehr_bier" }, :name => "pe" ) 
     63  end 
     64 
    6065  def test_form_remote_tag 
    6166    assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater('glass_of_beer', 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\">), 
    6267      form_remote_tag(:update => "glass_of_beer", :url => { :action => :fast  }) 
  • actionpack/lib/action_view/helpers/prototype_helper.rb

    old new  
    142142      def periodically_call_remote(options = {}) 
    143143         frequency = options[:frequency] || 10 # every ten seconds by default 
    144144         code = "new PeriodicalExecuter(function() {#{remote_function(options)}}, #{frequency})" 
     145         if name = options.delete(:name) then code = "var #{name} = " + code end 
    145146         javascript_tag(code) 
    146147      end 
    147148