Home arrow Ruby-on-Rails arrow Page 2 - Dropping and Sorting with AJAX and script.aculo.us
RUBY-ON-RAILS

Dropping and Sorting with AJAX and script.aculo.us


In this conclusion to a three-part series that explains how to use script.aculo.us on Rails, you'll learn dropping and sorting. This article is excerpted from chapter four of Ajax on Rails, written by Scott Raymond (O'Reilly, 2007; ISBN: 0596527446). Copyright © 2007 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media.

Author Info:
By: O'Reilly Media
Rating: 4 stars4 stars4 stars4 stars4 stars / 8
November 29, 2007
TABLE OF CONTENTS:
  1. · Dropping and Sorting with AJAX and script.aculo.us
  2. · Droppables with Ajax
  3. · Sortables
  4. · Ajax-enabled sortables

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Dropping and Sorting with AJAX and script.aculo.us - Droppables with Ajax
(Page 2 of 4 )

All the options specified in the previous section are available whether you create your droppable with JavaScript (Droppables.add) or the Rails helpers (drop_receiving_elementanddrop_receiving_element_js). However, when created with the helpers, some additional options are available. Namely, all thelink_to_remoteoptions, such asupdate andurl(described in Chapter 3), are also available, and will be used to create anonDropcallback function for doing Ajax calls with droppables. For example:

  <div id="drag" class="green box">drag </div>
  <%= draggable_element :drag, :revert => true %>

  <div id="drop" class="pink box">drop</div>
  <%= drop_receiving_element :drop, :hoverclass => "hover",
       :update => "status", :url => { :action => "receive_drop" } %>

  <div id="status"></div>

Notice that the:urloption points to areceive_dropaction, so we’ll need to define that in chapter4_controller.rb:

  def receive_drop
    render :text => "you dropped element id #{params[:id]}"
  end

Unless overridden by the:withoption, thedrop_receiving_elementAjax call will automatically include the ID of the draggable as theidparameter of the request.


blog comments powered by Disqus
RUBY-ON-RAILS ARTICLES

- Adding Style with Action Pack
- Handling HTML in Templates with Action Pack
- Filters, Controllers and Helpers in Action P...
- Action Pack and Controller Filters
- Action Pack Categories and Events
- Logging Out, Events and Templates with Actio...
- Action Pack Sessions and Architecture
- More on Action Pack Partial Templates
- Action Pack Partial Templates
- Displaying Error Messages with the Action Pa...
- Action Pack Request Parameters
- Creating an Action Pack Registration Form
- Ruby on Rails Templates and Layouts
- Action Pack Controller Creation
- Writing an Action Pack Controller

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 9 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials