Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This plugin adds drag and drop functionality using json.

Almost all the code of this plugin originates from: code.google.com/p/nestedsortables/ so the credits should go there.

To install use:

git@github.com:bterkuile/nested_sortable.git

Done!

  • You are using jQuery, this will not work with another library

  • You have git installed

  • You use this on your own risk

There are some assumptions/defaults for this plugin. Based on these I will give a simple setup of an example use.

rails g scaffold Page title:string parent_id:integer position:integer

Make sure that the position has a default value, otherwise errors may occur

rake db:migrate

in app/controllers/pages_controller :

nested_sortable_data_source_for :page, :columns => [[:title, 'My title'], [:created_at, 'Created:']]

in your layout in the head section (haml style):

= include_nested_sortable_if_needed
resources :pages do
  collection do
    get :order
    post :order
  end
end

In your view (assuming jQuery is already used in the project, and haml) :javascript

$(function(){
  $('#pages_tree').NestedSortableWidget({
    loadUrl: "#{url_for(:action => :order, :format => :json)}",
    saveUrl: "#{url_for(:action => :order, :format => :json)}",
    handle: true,
    text:{
      handle: "[drag]",
      saveButton: "Update hierarchy"
    },
    colsWidth: [300]
  });
});

And now you’re done

About

This plugin adds nested drag and drop functionality using json for acts_as_tree

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages