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

Ticket #8299 (closed defect: fixed)

Opened 1 year ago

Last modified 7 months ago

drop_receiving_element doesn't quote confirm option

Reported by: xtoddx Assigned to: madrobby
Priority: normal Milestone: 2.x
Component: script.aculo.us Version: edge
Severity: normal Keywords: Droppables verified
Cc:

Description

When making a drop_receiving_element with a :confirm=>'really do it?', the confirm works well for the Ajax.Updater, but the confirm is also in the Droppables.add() options, and it is unquoted, which leads to a javascript error.

Rails 1.2.3

Sample:

<%= drop_receiving_element('photo_trash', :hoverclass=>'dropready', :url=>{:action=>'aj_image_delete'}, :confirm=>"Really delete image?") %>

Yields:

Droppables.add("photo_trash", {confirm:Really delete image?, hoverclass:'dropready', onDrop:function(element){if (confirm('Really delete image?')) { new Ajax.Request('/office/aj_image_delete', {asynchronous:true, evalScripts:true, parameters:'id=' + encodeURIComponent(element.id)}); }}})

Attachments

fix_confirmation_for_drop_receiving_element.diff (2.1 kB) - added by thechrisoshow on 02/12/08 23:27:19.
This patch file ensures that the :confirm option works without having to supply extra quotes on the drop_receiving_element helper

Change History

(in reply to: ↑ description ) 06/29/07 09:01:24 changed by BigTitus

Replying to xtoddx:

When making a drop_receiving_element with a :confirm=>'really do it?', the confirm works well for the Ajax.Updater, but the confirm is also in the Droppables.add() options, and it is unquoted, which leads to a javascript error. Rails 1.2.3 Sample: {{{ <%= drop_receiving_element('photo_trash', :hoverclass=>'dropready', :url=>{:action=>'aj_image_delete'}, :confirm=>"Really delete image?") %> }}} Yields: {{{ Droppables.add("photo_trash", {confirm:Really delete image?, hoverclass:'dropready', onDrop:function(element){if (confirm('Really delete image?')) { new Ajax.Request('/office/aj_image_delete', {asynchronous:true, evalScripts:true, parameters:'id=' + encodeURIComponent(element.id)}); }}}) }}}

Same problem for :submit. Adds "parameters:Form.serialize('form_id')" correctly but even a "submit:form_id" which leads to the mentioned javascript error.

02/12/08 23:27:19 changed by thechrisoshow

  • attachment fix_confirmation_for_drop_receiving_element.diff added.

This patch file ensures that the :confirm option works without having to supply extra quotes on the drop_receiving_element helper

02/12/08 23:28:54 changed by thechrisoshow

[PATCH] This is caused by the :confirm option being passed through to the Droppables.add javascript method - where it doesn't get used and basically throws up.

Attached is a tiny little patch that ensures that the :confirm option is thrown away once it serves its purpose, and doesn't despoil the Droppable.add method.

SO this:

drop_receiving_element('photo_trash', :hoverclass=>'dropready', :url=>{:action=>'aj_image_delete'}, :confirm=>"Really delete image?") %>

generates this:

Droppables.add("photo_trash", {hoverclass:'dropready', onDrop:function(element){if (confirm('Really delete image?')) { new Ajax.Request('/office/aj_image_delete', {asynchronous:true, evalScripts:true, parameters:'id=' + encodeURIComponent(element.id)}); }}})

instead of this:

Droppables.add("photo_trash", {confirm:Really delete image?, hoverclass:'dropready', onDrop:function(element){if (confirm('Really delete image?')) { new Ajax.Request('/office/aj_image_delete', {asynchronous:true, evalScripts:true, parameters:'id=' + encodeURIComponent(element.id)}); }}})

(This patch includes a little test to verify it works)

02/13/08 09:37:51 changed by h-lame

+1, seems to work

02/13/08 10:48:02 changed by snowblink

+1

02/13/08 10:53:55 changed by Kabish

+1

02/14/08 12:39:03 changed by thechrisoshow

  • keywords changed from Droppables to Droppables verified.

02/16/08 00:07:55 changed by nzkoz

  • status changed from new to closed.
  • resolution set to fixed.

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