The previous answer was fairly sufficient, with the exception that it never addressed the tripping breaker. When wiring a dimmer switch, it is larger than a standard switch and fills the box more, respectively. After Isolating the outlet, wire nut the dimmer switch as the original switch was wired. Dimmers have a current in and current out. If there are two white wires in the box they do not connect to the switch. They simply tie together. Then the black that feeds the outlet ties to the black that has power. You can tap the blacks together intermittently to decipher this code. The constant power in and constant power out tie together with one lead of the dimmer(black) then the light switch leg black will tie to the other black wire on the dimmer. All green / bare wires tie together.
If the switch box only has two wires in it (black and white) it was wired as a switch loop. Power was sent from the light box down to the switch(usually black) then returned on the opposite color. (usually white).That opposite color should go to the black of the light being switched and all other lights (black) down the line.
Be sure none of your re-installation pinches or forces hot wires to touch the box or grounded brackets, braces etc.
If the switch box only has two wires in it (black and white) it was wired as a switch loop. Power was sent from the light box down to the switch(usually black) then returned on the opposite color. (usually white).That opposite color should go to the black of the light being switched and all other lights (black) down the line.
Be sure none of your re-installation pinches or forces hot wires to touch the box or grounded brackets, braces etc.