Hi Hillyb,
I have had similar problems when trying to grow them in pots. A couple questions and possible answers:
Are/were they in full sun? Legginess in plants always makes me think they're reaching for light and cosmos really like the sun.
What was planted around/near them? If they were crowded, then they might also reach up high before blooming.
I didn't think that they would get that leggy though 
Patrick