Posts tagged with 'jquery'


Game on: jQuery each() vs. Array.prototype.forEach()

OK, so this afternoon I got bitten by an issue that has bitten a gazillion web developers (and will probably continue to bite more in the future). I’m talking about the syntax for the callback function that’s used for jQuery.each() versus that for JavaScript’s Array.prototype.forEach() . They are, dear reader, not the same . Let’s quickly show the difference. The callback for the jQuery.each() function should have calling syntax that looks like this:  function (index, element) whereas the one...

READ MORE

Extending jQuery

A couple of months ago, I was on a “Update All The Things” spree with my websites. In one of them, the blog I have for my Volvo 1800S , I’m using a purchased theme that I’ve left pretty much alone. It’s fine as far as it goes, a bit inefficient, but it did serve as a basis for my articles here on speeding up web pages ( 1 , 2 , 3 ). After I had written those it was time to fix the problems with the theme. Plan A was to upgrade it to the developer’s latest version. Except it was no longer available...

READ MORE

Upgrading to jQuery 1.9.x

Today it snowed. It started before we awoke and pretty much kept at it all day. Hence it was a day to do some work inside, and what better task than to clean up my blog? First port of call, and a major one at that, was to upgrade to jQuery 1.9. Before you say, so what, just change the version number in the <script> tag, consider this. jQuery 1.9 removes several APIs that “behaved inconsistently or inefficiently in the past” ( here ), ones that have been deprecated for a while. So, replacing...

READ MORE

JavaScript: handy hint for jQuery document ready handlers

Like 99% of all jQuery users, I write the code I want executed when the document is ready like this: $( function () { // code using $ for the jQuery function }); Except… What happens if someone calls $.noConflict() and $ is no longer valid? Do I have to resort to using jQuery() all over the place, just to be sure? Answer: no. It seems – and I only discovered this moments ago – the document ready handler gets passed the jQuery function as the first and only argument. You can write this instead: jQuery...

READ MORE

Minor changes to look-and-feel

I’ve been meaning to do a bit of housework on this site to clean up the CSS and to add a bit of interactivity. After all, I write a lot about JavaScript, so I might as well start adding some to my blog. photo © 2007 Dan Brady | more info (via: Wylio ) First things first: if things look a little wacky for you, your browser is probably using the old CSS file. Refresh. That should force the new CSS file to be downloaded and used. Second: the changes to the CSS are two-fold. The main impetus was to allow...

READ MORE

JavaScript for C# developers: writing a library (part 1)

From comments I received when I wrote my recent article over on my DevExpress ctodx blog, it seems there’s a need for people to understand how to write reusable code in the form of a library in JavaScript, and not fall into those nicely shaped C# potholes along the way. So I thought, let’s have a go. ( Update : I’ve made a couple of corrections to point out the files this code appears in.) Some ground rules first. The first is that I’m going to use jQuery . Although jQuery...

READ MORE