Ensure that :confirm doesn't need extra quotes when using drop_receiving_element. Closes #8299 [thechrisoshow]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8879 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Michael Koziarski 2008-02-16 00:07:52 +00:00
parent 4ff26f51f6
commit 86cb0a61fb
2 changed files with 6 additions and 1 deletions

@ -192,6 +192,9 @@ def drop_receiving_element_js(element_id, options = {}) #:nodoc:
options[:accept] = array_or_string_for_javascript(options[:accept]) if options[:accept] options[:accept] = array_or_string_for_javascript(options[:accept]) if options[:accept]
options[:hoverclass] = "'#{options[:hoverclass]}'" if options[:hoverclass] options[:hoverclass] = "'#{options[:hoverclass]}'" if options[:hoverclass]
# Confirmation happens during the onDrop callback, so it can be removed from the options
options.delete(:confirm) if options[:confirm]
%(Droppables.add(#{element_id.to_json}, #{options_for_javascript(options)});) %(Droppables.add(#{element_id.to_json}, #{options_for_javascript(options)});)
end end
end end

@ -88,8 +88,10 @@ def test_drop_receiving_element
drop_receiving_element("droptarget1", :accept => 'products', :update => 'infobox') drop_receiving_element("droptarget1", :accept => 'products', :update => 'infobox')
assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nDroppables.add(\"droptarget1\", {accept:['tshirts','mugs'], onDrop:function(element){new Ajax.Updater('infobox', 'http://www.example.com/', {asynchronous:true, evalScripts:true, parameters:'id=' + encodeURIComponent(element.id)})}})\n//]]>\n</script>), assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nDroppables.add(\"droptarget1\", {accept:['tshirts','mugs'], onDrop:function(element){new Ajax.Updater('infobox', 'http://www.example.com/', {asynchronous:true, evalScripts:true, parameters:'id=' + encodeURIComponent(element.id)})}})\n//]]>\n</script>),
drop_receiving_element("droptarget1", :accept => ['tshirts','mugs'], :update => 'infobox') drop_receiving_element("droptarget1", :accept => ['tshirts','mugs'], :update => 'infobox')
end assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nDroppables.add("droptarget1", {hoverclass:'dropready', onDrop:function(element){if (confirm('Are you sure?')) { new Ajax.Request('http://www.example.com/update_drop', {asynchronous:true, evalScripts:true, parameters:'id=' + encodeURIComponent(element.id)}); }}})\n//]]>\n</script>),
drop_receiving_element('droptarget1', :hoverclass=>'dropready', :url=>{:action=>'update_drop'}, :confirm => 'Are you sure?')
end
def protect_against_forgery? def protect_against_forgery?
false false
end end