ユーザーが静的フィールドに入力できるフォームがあります。それらの下にボタンを使用すると、動的に新しいフィールドを追加できます。
<form action="url" method="POST">
<table class="table" id="mytable">
<thead>
<tr>
<th>Foo</th>
<th>Bar</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<button id="new-field">Add new fields</button>
</form>
ここに私のJSコードがあります:
$('#new-field').click(function(e) {
e.preventDefault();
var i = $('#mytable tbody tr').length + 1;
$('<tr><td><input type="text" name="newfield['+ i +'][foo]"></td><td><input type="text" name="newfield['+ i +'][bar]]"></tr>').appendTo($('#mytable tbody'));
});
新しいフィールドは正しく表示されますが、(送信ボタンを使用して) フォームを投稿すると、新しいフィールドは IE9 では考慮されません... Firefox と Chrome で動作します。
どうやらここに解決策があります: Dynamically added form elements are not POSTED in IE 9 しかし、私のプロジェクトでは互換モードを使用できません。
解決策はありますか?