How to AJAXify any POSTed web form

Probably not too practical in real life, but I wanted to see just how easy it could be to implement this. If you want a lazy way to automatically convert any normal HTML POST form (send email, submit information, etc.) into a quicker-looking AJAX form, here’s the quickest way to do it:
Continue reading How to AJAXify any POSTed web form

Mobile Chrome removing 300ms click delay

300ms tap delay, gone away — and speculation about when and if this will spread to other browsers.

This may or may not affect some mobile JavaScript I’ve written. For instance, I’m currently putting the finishing touches on a tablet app that’s designed for private use, and therefore only will be used on a tablet, wherein I’ve hijacked the “touchstart” event like so:

$('selector').on('touchstart', function(e) {

…which works fine, as long as I’m trying to trigger JavaScript code and not a hyperlink click (which can’t be triggered by code due to browser security restrictions). I didn’t like doing so, but performance was of the essence. It’d be nice to do things the “correct” way and still get the maximum performance.

Hide and show options in a select dropdown

Problem: You want to hide and show certain <option>s in a <select> form element, but you can’t apply ‘display: none’ CSS to them because they’re the wrong kind of DOM element. Toggling the ‘disabled’ property only grays the <option> out, which isn’t as good as hiding it completely.

Solution: Using jQuery, we can .detach() the <select> into a global variable on page load, then add back only the <option>s you want on demand. Continue reading Hide and show options in a select dropdown