app/assets/javascripts/manage_repeating_fields.js in curate-0.2.0 vs app/assets/javascripts/manage_repeating_fields.js in curate-0.3.1
- old
+ new
@@ -35,21 +35,24 @@
$activeFieldControls = $activeField.children('.field-controls'),
$removeControl = this.remover.clone(),
$newField = $activeField.clone(),
$listing = $('.listing', this.element),
$warningSpan = $("<span class=\'message warning\'>cannot add new empty field</span>");
- if ($activeField.children('input').val() == '') {
+ if ($activeField.children('input').val() === '') {
$listing.children('.warning').remove();
$listing.append($warningSpan);
}
else{
$listing.children('.warning').remove();
$('.add', $activeFieldControls).remove();
$activeFieldControls.prepend($removeControl);
- $newField.children('input').val('');
- $newField.children('input').focus()
+ $newChildren = $newField.children('input');
+ $newChildren.
+ val('').
+ removeProp('required');
$listing.append($newField);
+ $newChildren.first().focus();
this._trigger("add");
}
},
remove_from_list: function( event ) {
@@ -64,8 +67,8 @@
_destroy: function() {
this.actions.remove();
$('.field-wrapper', this.element).removeClass("input-append");
this.element.removeClass( "managed" );
- },
+ }
});
})(jQuery);