projecthydra/hydra-head — Issue #1: id generation bug in HydraHead.add_keywords javascript in master
Author: barmintor
Created: 2011-10-18 19:43:21+00:00
State: open

In the current js, the added input tag's id is generated with a suffix calculated like so:

var keyword_count = $(this).parent().siblings('.fedora-text-field').length;

If there was more than one keyword value to begin with, those values will all be under a single p.fedora-text-field tag, but the above code will always give the new value an id of 'subject_topic_1'. Unless the text field scaffolding is reworked to place each input in its own p.fedora-text-field, the counting needs to be more along the lines of:

var keyword_count = 0;
var counts = $(this).parent().siblings('.fedora-text-field').map(
function(){
if ($(this).children('input[type="text"]')) {
return $(this).children('input[type="text"]').length;
} else return 0;
});
for (var i = 0; i < counts.length; i++) { keyword_count += counts[i]}