Ajax Tree Plugin

Posted by anup.narkhede on December 19, 2007

Introduction

This is a helper plugin to generate ajax based tree structure (two level). It can be used for two models having n:m or 1:n relationships. A leaf from any branch can be dragged and dropped in another branch. A scaffolding arrangement is also done to create a new branch, add leaf etc.

Sceenshot

For example:

Installation:

Here we take the previous example of Category and Article models. Generate the ajax controller for the two models.

Usage

Example

Copy static files

Copy add.png, delete.png from /vendor/plugins/ajax_tree/ directory to /public/images directory.

Copy ajax_tree.css file from /vendor/plugins/ajax_tree/ directory to /public/stylesheets/ directory.
Include css in your application layout

Call the helpers

Specify model names for branch model and leaf model in /views/home/_show_ajax_tree.rhtml partial.

Then, call this partial in any rhtml, where you want to display the ajax tree. In this case, we have done it in /views/home/index.rhtml

home_controller.rb (Generated automatically)

index.rhtml

Contributions:

This project is hosted at http://code.google.com/p/ajax-tree/. Please leave your feedback.

Trackbacks

Use this link to trackback from your own site.

Comments

Leave a response

  1. Rymaï Wed, 19 Dec 2007 17:12:53 PST

    ” in /views/home/show_ajax_tree.rhtml partial.”

    should be (add “_” to the partial name) :

    ” in /views/home/_show_ajax_tree.rhtml partial.”

    I think it’s a typing-error, it’s not very critical but … perfection is perfection ^^.

    I’ll probably test this plugin… more feedback soon!

    Rymaï

  2. anup.narkhede Sun, 23 Dec 2007 22:51:58 PST

    Hey, thanks for pointing it out. It was a silly typo from me.

Comments