Added getnext and prev index, set index from elems and emit events.