Permalink
Browse files

Updated awesome_nested_fields to version 0.6.0.

  • Loading branch information...
1 parent 391610e commit be79f220cde2f8ddcd4a98f46d2ae1b4bdfe1122 @lailsonbm committed Dec 25, 2011
View
@@ -3,7 +3,7 @@ source 'http://rubygems.org'
gem 'rails', '3.0.11'
gem 'jquery-rails'
-gem 'awesome_nested_fields', path: '../awesome_nested_fields'
+gem 'awesome_nested_fields', '0.6.0'
gem 'sqlite3'
gem 'awesome_print'
@@ -17,7 +17,7 @@
</div>
<h2>Phones</h2>
- <div class="container">
+ <div class="items">
<%= f.nested_fields_for :phones do |f|
render 'phone', f: f
end -%>
@@ -17,7 +17,7 @@
</div>
<h2>Phones</h2>
- <div class="container">
+ <div class="items">
<%= f.fields_for :phones do |builder| %>
<%= render 'phone', f: builder %>
<% end %>
@@ -15,7 +15,7 @@
afterRemove: function(item) {},
itemTemplateSelector: '.item.template',
emptyTemplateSelector: '.empty.template',
- containerSelector: '.container',
+ containerSelector: '.items, .container',
itemSelector: '.item',
emptySelector: '.empty',
addSelector: '.add',
@@ -29,7 +29,7 @@
init: function(options) {
return this.each(function() {
var $this = $(this);
- if($(this).data('nested-fields.options')) {
+ if($this.data('nested-fields.options')) {
log('Nested fields already defined for this element. If you want to redefine options, destroy it and init again.');
return $this;
}
@@ -42,7 +42,7 @@
$this.data('nested-fields.options', options);
bindInsertToAdd(options);
- bindRemoveToItems(options);
+ bindRemoveToItems(options, $this);
});
},
@@ -105,8 +105,8 @@
});
}
- function bindRemoveToItems(options) {
- $(options.itemSelector, options.containerSelector).each(function(i, item) {
+ function bindRemoveToItems(options, $this) {
+ $(options.itemSelector, $this).each(function(i, item) {
bindRemoveToItem(item, options);
});
}
@@ -178,7 +178,7 @@
if(!options.skipBefore) {
options.beforeRemove($element, remove);
if(options.beforeRemove.length <= 1) {
- insert();
+ remove();
}
} else {
remove();

0 comments on commit be79f22

Please sign in to comment.