Two things I’ve learned recently:
- Don’t use “icons” as a folder name in a website directory if you’re on Apache. Everything inside will 404. Apparently Apache aliases any directory named icons to its own icons directory by default with no .htaccess override allowed. This falls into the “but why did it work on my computer?” category, since I didn’t change any defaults when I installed MAMP.
- If you’re dynamically adding elements to a webpage and you want JavaScript (with jQuery) to react to clicks on them, you can’t use
$('.desired-class').click(function(e) { … });
– that will only bind clicks to elements that already exist when the JavaScript is loaded. Instead, you need to bind a click handler to the entire page:$(document).on('click', '.desired-class', function(e) { … });
In other news, I added a new repo to Github over the weekend: a door prize program. We designed it for the Boston Small Business Expo as a way to entice people to give us their email addresses. It requires name and email, allows organization and phone number, and has a function to draw three winners and also export all entrants as a CSV file. If you want to use it and have questions around adapting it, let me know!
Lottery number globe from Pixabay.