diff --git a/app/assets/javascripts/cocoon.js b/app/assets/javascripts/cocoon.js
index 17fd400..c9bd8ee 100644
--- a/app/assets/javascripts/cocoon.js
+++ b/app/assets/javascripts/cocoon.js
@@ -18,7 +18,7 @@
var $this = $(this),
assoc = $this.data('association'),
assocs = $this.data('associations'),
- content = $this.data('template'),
+ content = $this.data('association-insertion-template'),
insertionMethod = $this.data('association-insertion-method') || $this.data('association-insertion-position') || 'before';
insertionNode = $this.data('association-insertion-node'),
regexp_braced = new RegExp('\\[new_' + assoc + '\\]', 'g'),
diff --git a/lib/cocoon/view_helpers.rb b/lib/cocoon/view_helpers.rb
index dca2979..aa12a63 100644
--- a/lib/cocoon/view_helpers.rb
+++ b/lib/cocoon/view_helpers.rb
@@ -73,7 +73,7 @@ module Cocoon
html_options[:'data-associations'] = association.to_s.pluralize
new_object = create_object(f, association)
- html_options[:'data-template'] = CGI.escapeHTML(render_association(association, f, new_object, render_options, override_partial)).html_safe
+ html_options[:'data-association-insertion-template'] = CGI.escapeHTML(render_association(association, f, new_object, render_options, override_partial)).html_safe
link_to(name, '#', html_options )
end
diff --git a/spec/cocoon_spec.rb b/spec/cocoon_spec.rb
index b1a4b1e..46f5231 100644
--- a/spec/cocoon_spec.rb
+++ b/spec/cocoon_spec.rb
@@ -21,19 +21,19 @@ describe Cocoon do
context "without a block" do
it "accepts a name" do
result = @tester.link_to_add_association('add something', @form_obj, :comments)
- result.to_s.should == 'add something'
+ result.to_s.should == 'add something'
end
it "accepts html options and pass them to link_to" do
result = @tester.link_to_add_association('add something', @form_obj, :comments, {:class => 'something silly'})
- result.to_s.should == 'add something'
+ result.to_s.should == 'add something'
end
it "allows to explicitly hand the wanted partial" do
@tester.unstub(:render_association)
@tester.should_receive(:render_association).with(anything(), anything(), anything(), anything(), "shared/partial").and_return('partiallll')
result = @tester.link_to_add_association('add something', @form_obj, :comments, :partial => "shared/partial")
- result.to_s.should == 'add something'
+ result.to_s.should == 'add something'
end
end
@@ -42,14 +42,14 @@ describe Cocoon do
result = @tester.link_to_add_association(@form_obj, :comments) do
"some long name"
end
- result.to_s.should == 'some long name'
+ result.to_s.should == 'some long name'
end
it "accepts html options and pass them to link_to" do
result = @tester.link_to_add_association(@form_obj, :comments, {:class => 'floppy disk'}) do
"some long name"
end
- result.to_s.should == 'some long name'
+ result.to_s.should == 'some long name'
end
it "allows to explicitly hand the wanted partial" do
@@ -58,21 +58,21 @@ describe Cocoon do
result = @tester.link_to_add_association( @form_obj, :comments, :class => 'floppy disk', :partial => "shared/partial") do
"some long name"
end
- result.to_s.should == 'some long name'
+ result.to_s.should == 'some long name'
end
end
context "with an irregular plural" do
it "uses the correct plural" do
result = @tester.link_to_add_association('add something', @form_obj, :people)
- result.to_s.should == 'add something'
+ result.to_s.should == 'add something'
end
end
context "when using aliased association and class-name" do
it "uses the correct name" do
result = @tester.link_to_add_association('add something', @form_obj, :admin_comments)
- result.to_s.should == 'add something'
+ result.to_s.should == 'add something'
end
end
@@ -84,7 +84,7 @@ describe Cocoon do
it "uses the correct plural" do
@tester.should_receive(:render_association).with(:people, @form_obj, anything, {:wrapper => 'inline'}, nil)
result = @tester.link_to_add_association('add something', @form_obj, :people, :render_options => {:wrapper => 'inline'})
- result.to_s.should == 'add something'
+ result.to_s.should == 'add something'
end
end
@@ -94,14 +94,14 @@ describe Cocoon do
@form_obj.should_receive(:fields_for) { | association, new_object, options_hash, &block| block.call }
@tester.should_receive(:render).with("person_fields", {:f=>nil, :dynamic=>true, :alfred=>"Judoka"}).and_return ("partiallll")
result = @tester.link_to_add_association('add something', @form_obj, :people, :render_options => {:wrapper => 'inline', :locals => {:alfred => 'Judoka'}})
- result.to_s.should == 'add something'
+ result.to_s.should == 'add something'
end
it "if no locals are given it still works" do
@tester.unstub(:render_association)
@form_obj.should_receive(:fields_for) { | association, new_object, options_hash, &block| block.call }
@tester.should_receive(:render).with("person_fields", {:f=>nil, :dynamic=>true}).and_return ("partiallll")
result = @tester.link_to_add_association('add something', @form_obj, :people, :render_options => {:wrapper => 'inline'})
- result.to_s.should == 'add something'
+ result.to_s.should == 'add something'
end
end
@@ -116,7 +116,7 @@ describe Cocoon do
@form_obj.should_receive(:semantic_fields_for)
@form_obj.should_receive(:fields_for).never
result = @tester.link_to_add_association('add something', @form_obj, :people)
- result.to_s.should == 'add something'
+ result.to_s.should == 'add something'
end
end
@@ -132,7 +132,7 @@ describe Cocoon do
@form_obj.should_receive(:simple_fields_for)
@form_obj.should_receive(:fields_for).never
result = @tester.link_to_add_association('add something', @form_obj, :people)
- result.to_s.should == 'add something'
+ result.to_s.should == 'add something'
end
end