jstree_rails 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ == v0.1.2
2
+ * Adds .jstree_rails class to all generated divs containing trees
3
+ * Adds support for defining ajax options when building send link
4
+
1
5
  == v0.1.1
2
6
  * Fix for #jstree output to be properly labeled as safe
3
7
 
@@ -14,5 +14,5 @@ module JsTreeRails
14
14
  end
15
15
  end
16
16
 
17
- VERSION = Version.new('0.1.1')
17
+ VERSION = Version.new('0.1.2')
18
18
  end
@@ -4,7 +4,7 @@ module JsTreeRails
4
4
  include RailsJavaScriptHelpers
5
5
 
6
6
  def jstree(dom_id, options={})
7
- ("<div id=\"#{dom_id.sub(/^#/, '')}\"></div>" +
7
+ ("<div id=\"#{dom_id.sub(/^#/, '')}\" class=\"jstree-rails\"></div>" +
8
8
  javascript_tag{
9
9
  "jQuery(function(){
10
10
  jQuery('#{format_id(dom_id)}').jstree(
@@ -16,14 +16,19 @@ module JsTreeRails
16
16
  end
17
17
 
18
18
  # Send entire tree structure (-1 forces entire tree. update to make configurable)
19
- def jstree_send_link(name, dom_id, url_or_path, args={})
20
- link_to_function(name, args) do |page|
19
+ def jstree_send_link(name, dom_id, url_or_path, link_args={}, ajax_args={})
20
+ built_ajax_args = {
21
+ :type => link_args.delete(:method) || 'post',
22
+ :data => {
23
+ :data => RawJS.new("jQuery(#{format_type_to_js(format_id(dom_id))}).jstree('get_json', -1)")
24
+ }
25
+ }.merge(ajax_args)
26
+ link_to_function(name, link_args) do |page|
21
27
  page << "
22
28
  jQuery.ajax(
23
- #{format_type_to_js(url_or_path)}, {
24
- type : #{format_type_to_js(args[:method] || 'post')},
25
- data : {data : jQuery(#{format_type_to_js(format_id(dom_id))}).jstree('get_json', -1)}
26
- })"
29
+ #{format_type_to_js(url_or_path)},
30
+ #{format_type_to_js(built_ajax_args)}
31
+ )"
27
32
  end
28
33
  end
29
34
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jstree_rails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Chris Roberts
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-14 00:00:00 -07:00
18
+ date: 2011-08-12 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency