Ticket #1269: link_to_post.diff
| File link_to_post.diff, 3.1 kB (added by nzkoz, 3 years ago) |
|---|
-
actionpack/test/template/javascript_helper.rb
old new 5 5 6 6 def test_escape_javascript 7 7 assert_equal %(This \\"thing\\" is really\\n netos\\'), escape_javascript(%(This "thing" is really\n netos')) 8 end 9 10 def test_link_to_post 11 expected = %(<form action="/blah" method="post"><a href="#" onclick="this.parentNode.submit(); return false;">test</a></form>) 12 13 assert_equal(expected, link_to_post("test", :controller=>"blah")) 8 14 end 9 15 end -
actionpack/lib/action_view/helpers/javascript_helper.rb
old new 121 121 function = "#{function}; #{options[:after]}" if options[:after] 122 122 function = "if (#{options[:condition]}) { #{function}; }" if options[:condition] 123 123 function = "if (confirm('#{escape_javascript(options[:confirm])}')) { #{function}; }" if options[:confirm] 124 124 125 125 return function 126 126 end 127 127 128 def link_to_post(name, options={}, html_options = {}) 129 s = form_tag(options) 130 s << link_to_function(name, "this.parentNode.submit()", html_options) 131 s << "</form>" 132 return s 133 end 134 135 128 136 # Includes the Action Pack Javascript library inside a single <script> 129 137 # tag. 130 138 # … … 182 190 js_options['asynchronous'] = options[:type] != :synchronous 183 191 js_options['method'] = options[:method] if options[:method] 184 192 js_options['insertion'] = "Insertion.#{options[:position].to_s.camelize}" if options[:position] 185 193 186 194 if options[:form] 187 195 js_options['parameters'] = 'Form.serialize(this)' 188 196 elsif options[:with] -
actionpack/lib/action_view/helpers/asset_tag_helper.rb
old new 110 110 source = "/#{dir}/#{source}" unless source.include?("/") 111 111 source = "#{source}.#{ext}" unless source.include?(".") 112 112 source = "#{@request.relative_url_root}#{source}" 113 @controller.asset_host + source113 ActionController::Base.asset_host + source 114 114 end 115 115 end 116 116 end