To understand why an ionic bond happens between a non-metal and a metal we first have to understand why bonds are made in the first place. All atoms want to do is be stable! To become stable they must have a completely full outer shell, this can be achieved by either gaining or losing an electron, so if you had an atom such as Na which only has 1 electron in it's outer shell (2,8,1) you know that it is going to be desperate to lose said electron. On the other hand if you had an atom such as Cl which has 7 electrons in it's outer shell (2,8,7) it is going to be desperate to gain one electron. As you can see it is beneficial to both atoms to donate/take an electron! So Na would give it's outer shell electron to Cl and the new electronic configurations would be (2,8) and (2,8,8) respectively. Because Na has lost an electron it becomes positive (because electrons are negatively charged) and because Cl has gained an electron it becomes negatively charged - these are now IONS! The two opposite forces attract each other and form a bond, this is an ionic bond and the attraction is known as electrostatic attraction - just remember it as opposites attracting!