improved handling of jquery element reordering