I am using prototype and have the following javascript:
function displayDefinition(term){
var term_id = term.gsub(/[ '’]/,"_");
$(term_id).observe('click', function() {
new Ajax.Request('/terms/display_definition',
{parameters: {
term: term,
}})
})
}
I am having very strange behavior when the term is the string “content”. Is this an invalid javascript variable name? And if so, what is the best way to get around it?
I think that it’s because there’s already another element with the id
contentin the document. It isn’t allowed to have multiple elements with the sameidattribute. Use ids that aren’t already being used for something else.