Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

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

#966

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

Reported by 47primes · September 3rd, 2008 @ 07:21 PM

State: invalid
Milestone: 3.x
Assigned to: nobody
Importance: Low

Activity

  1. Pratik
    Pratik
    • State changed from new to incomplete

    Please have a look at http://rails.lighthouseapp.com/p...

    Thanks.

    September 3rd, 2008 @ 07:49 PM

  2. Wei Tian
    Wei Tian

    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.

    October 9th, 2008 @ 11:41 AM

  3. Ryan Bigg
    Ryan Bigg

    Please either submit a patch or this ticket should be closed. Thanks!

    April 10th, 2010 @ 08:46 AM

  4. Ryan Bigg
    Ryan Bigg

    Please either submit a patch or this ticket should be closed. Thanks!

    April 10th, 2010 @ 10:55 AM

  5. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.x to 3.x

    May 4th, 2010 @ 06:48 PM

  6. Rohit Arondekar
    Rohit Arondekar
    • 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.

    June 15th, 2010 @ 11:54 AM

  7. Ryan Bigg
    Ryan Bigg
    • Tag cleared.

    Automatic cleanup of spam.

    October 9th, 2010 @ 10:04 PM

  8. Aditya Sanghi
    Aditya Sanghi

    Automatic cleanup of spam.

    October 9th, 2010 @ 10:05 PM