2 function tabHandler(event) {
5 // key was pressed in last row
6 if (event.which == 9 &&
7 (!$(this).closest('div.keyword-form-row').next().hasClass('keyword-form-row'))) {
12 function addForm(event) {
13 var prototypeForm = $('#keyword-form-prototype div.keyword-form-row').clone().appendTo('#keyword-form-rows');
14 var newForm = $('.keyword-form-row:last');
15 var totalForms = $('#id_form-TOTAL_FORMS').attr('value');
16 var newIdRoot = 'id_form-' + totalForms + '-';
17 var newNameRoot = 'form-' + totalForms + '-';
19 var keywordInput = newForm.find('.keyword');
20 keywordInput.attr('id', newIdRoot + 'keyword');
21 keywordInput.attr('name', newNameRoot + 'keyword');
23 var definitionInput = newForm.find('.definition');
24 definitionInput.attr('id', newIdRoot + 'definition');
25 definitionInput.attr('name', newNameRoot + 'definition');
26 definitionInput.keydown(tabHandler);
28 var objectIdInput = newForm.find('.object-id');
29 objectIdInput.attr('id', newIdRoot + 'id');
30 objectIdInput.attr('name', newNameRoot + 'id');
32 $('#id_form-TOTAL_FORMS').attr('value', parseInt(totalForms)+1);
36 $('.definition').keydown(tabHandler);
37 $('#add-row-btn').click(addForm);