Fix JavaScript bug (refs #293)