This project is archived and is in readonly mode.
Add options to ScriptaculousHelper.drop_receiving_element_js to pass commands before and after Ajax call
Reported by 47primes | September 3rd, 2008 @ 07:21 PM | in 3.x
This version of drop_receiving_element_js adds two additional options, beforeAjax and afterAjax, that provide a means for javascript code to be executed before and after the creation of the Ajax.Request object.
def drop_receiving_element_js(element_id, options = {}) #:nodoc:
options[:with] ||= "'id=' + encodeURIComponent(element.id)"
beforeAjax = options[:beforeAjax] ? options[:beforeAjax] + ';' : ''
afterAjax = options[:afterAjax] ? options[:afterAjax] + ';' : ''
options.delete(:beforeAjax)
options.delete(:afterAjax)
options[:onDrop] ||= "function(draggable,droppable,event){" + beforeAjax + remote_function(options) + ';' + afterAjax + "}"
options.delete_if { |key, value| PrototypeHelper::AJAX_OPTIONS.include?(key) }
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
Comments and changes to this ticket
-
Pratik September 3rd, 2008 @ 07:49 PM
- State changed from new to incomplete
Please have a look at http://rails.lighthouseapp.com/p...
Thanks.
-
Wei Tian October 9th, 2008 @ 11:41 AM
I have a slightly different scenario:
What if we want remote_function to construct the Ajax.Request URL dynamically at the javascript run-time? It's not possible with the current remote_function implementation, and doesn't seem to be covered by this ticket.
For example, we want the URL to be '/users/' + element.id, where element is the one got drag-and-dropped.
I could of course create a new ticket, but think it's best to put it here.
Thanks.
-
Ryan Bigg April 10th, 2010 @ 08:46 AM
Please either submit a patch or this ticket should be closed. Thanks!
-
Ryan Bigg April 10th, 2010 @ 10:55 AM
Please either submit a patch or this ticket should be closed. Thanks!
-
Rohit Arondekar June 15th, 2010 @ 11:54 AM
- State changed from incomplete to invalid
Since nobody has responded to Ryan's comment, I'm closing this ticket. Comment with a patch and I'll reopen it.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>