function replaceIfEmpty(fieldID, value){
alert($j('input#'+fieldID.val()));
if ($j('input#'+fieldID).val() == ""){
$j('input#'+fieldID).val(value);
}
}
there's my function, and this is in my controller:
page << "replaceIfEmpty('object_name', '#{t.name}');"
but when all this is invoked, an alert tells me:
RJS error:
TypeError: Object object_name has no method 'val'
even though I'm using jQuery 1.3.2, the docs say .val() isn't new to 1.4 =\
Your parenthesis are a bit off, this:
Should be:
Currently you're trying to call
.val()on the stringfieldID, rather than the jQuery object.A bit of a tangent from the issue here: If you upgrade to 1.4+ you can make this a bit shorter by passing a function to
.val(), like this: