How To Manage Javascript Callbacks
Posted on 30 September 2012 in Programming
tldr; Abstract anonymous functions into named functions to avoid nesting callbacks. Avoid using local variables of a shared scope in nested anonymous functions. Abstract large JavaScript object declaration into smaller generator functions. Or 'How To Avoid Callback Hell'. I have been meaning to write this post for some time now. Basically since Node.js came onto the spotlight and people started complaining about JavaScript code maintainability and readability due to nested callbacks and other asynchronous patterns....
Disable Any Element With jQuery
Posted on 05 July 2012 in Code
In HTML the disabled attribute alows you to mark an input element as 'disabled' Which will trigger the browser to render the input in a 'greyed out' style: Enabled elements Click Select Disabled elements Click Select This is helpful for limiting user interaction when an app is in an unknown state. Like waiting for an Ajax response. However this attribute is only available on form input elements. This is unfortunate if you are heavily using...
jquery autobox plugin
Posted on 30 October 2010
I have worked on several site designs that expect form inputs to render with a default value. Upon focus of the input the default text should clear and allow user input to stick. Sometimes the design calls for this to happen with a password field as well. Password fields are a special condition as the text is rendered as dots. You cannot dynamically change the 'type' attribute of a password input field. This is a...
IE button bug
Posted on 05 September 2010
I recently encountered an annoying bug in multiple versions of IE regarding forms and button elements. I am writing about it to remind myself in the future and to hopefully save time for someone else. The bug spawned from my decision to use <button> elements over <input type="submit"> elements as the submit buttons for my forms. I chose button elements because they are generally more consistent in cross browser rendering and also allow for more...