How exactly did Mendeleev discover his periodic table of 1869?

The usual version of how Mendeleev arrived at his discovery goes something like this. While in the process of writing his textbook, ‘The Principles of Chemistry’, Mendeleev completed the book by dealing with only eight of the then known sixty-three elements. He ended the book with the halogens.