Самая странная ошибка, которую я когда-либо встречал. Шучу, но определенно наверху.
Если бы я создал динамическую форму, как это ..
= form_tag main_index_path, :method => :post do
.payment
= text_field_tag "payments[0][:date_paid]"
= text_field_tag "payments[0][:amount_paid]"
%br/
= link_to 'Add Another Payment', '#', :class => "add_another"
.actions
%br/
= submit_tag 'calculate'
И нажмите на 'Add Another Payment'
Новый div .payment будет выглядеть так:
.payment
= text_field_tag "payments[1][:date_paid]"
= text_field_tag "payments[1][:amount_paid]"
Как ни странно, только в IE6 и IE7, он будет пропускать только первые и последние платежей
Как / Почему / Что я могу сделать, чтобы это исправить?
Для справки, вот метод 'add_another':
$(".add_another").click(function(){
if ($(".payment:last").find("input").val() != "") {
var $newdiv = $(".payment:last").clone(true);
$newdiv.find('input').each(function() {
var $this = $(this);
$this.attr('id', $this.attr('id').replace(/_(\d+)_/, function($0, $1) {
return '_' + (+$1 + 1) + '_';
}));
$this.attr('name', $this.attr('name').replace(/\[(\d+)\]/, function($0, $1) {
return '[' + (+$1 + 1) + ']';
}));
$this.val('');
});
$newdiv.find('textarea').each(function(){
var $this = $(this);
$this.attr('id', $this.attr('id').replace(/_(\d+)_/, function($0, $1) {
return '_' + (+$1 + 1) + '_';
}));
$this.attr('name', $this.attr('name').replace(/\[(\d+)\]/, function($0, $1) {
return '[' + (+$1 + 1) + ']';
}));
$this.css("color","#cccccc");
});
$newdiv.insertAfter('.payment:last').hide().slideDown();
};
return false;
});