README.md in dynatree-rails-0.0.1 vs README.md in dynatree-rails-0.0.2

- old
+ new

@@ -22,17 +22,50 @@ //= require dynatree/skin or - //= require dynatree/skin-vista + //= require dynatree/skin js: //= require dynatree/jquery.dynatree For dynatree usage and examples see: http://code.google.com/p/dynatree/ - + +## An optional model-to-javascript tree renderer for mongoid_nested_set + +Can be used to turn association select to a tree select, like this: + + #checkboxes + = f.association :categories, as: :check_boxes, collection: Category.all + #tree.controls.input{style: 'width: 220px;'} + + :javascript + var categories = #{Dynatree::Renderer.new(Category.nested_set.all, f.object.categories).render()}; + $(function(){ + $('#checkboxes').hide(); + + $("#tree").dynatree({ + checkbox: true, + selectMode: 3, + classNames: { + active: "dynatree-active-no" + }, + children: categories + }); + + $("form").submit(function() { + var tree = $("#tree").dynatree("getTree"), + arr = tree.serializeArray(), + sel = $('#restaurant_category_ids'); + sel.find('option:selected').removeAttr('selected'); + $.each(arr, function(k, v) { + sel.find('[value=' + v.value + ']').prop('selected', 'selected'); + }); + }); + }); + ## Contributing 1. Fork it 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Added some feature'`)