diff options
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_view/helpers/scriptaculous_helper.rb | 3 | ||||
-rw-r--r-- | actionpack/test/template/scriptaculous_helper_test.rb | 4 |
2 files changed, 6 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/scriptaculous_helper.rb b/actionpack/lib/action_view/helpers/scriptaculous_helper.rb index f7a9daf606..69fab27ac8 100644 --- a/actionpack/lib/action_view/helpers/scriptaculous_helper.rb +++ b/actionpack/lib/action_view/helpers/scriptaculous_helper.rb @@ -192,6 +192,9 @@ module ActionView options[:accept] = array_or_string_for_javascript(options[:accept]) if options[:accept] 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)});) end end diff --git a/actionpack/test/template/scriptaculous_helper_test.rb b/actionpack/test/template/scriptaculous_helper_test.rb index 8d55804fee..91856ff980 100644 --- a/actionpack/test/template/scriptaculous_helper_test.rb +++ b/actionpack/test/template/scriptaculous_helper_test.rb @@ -88,8 +88,10 @@ class ScriptaculousHelperTest < Test::Unit::TestCase 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>), 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? false end |