24 Jun 2013, 08:42
Portrait-robert_pragsmall

Robert Dober (20 posts)

Seems the site is down, or is this rather a technical error for the Errata?

25 Jun 2013, 19:35
Bphogan_pragsmall

Brian P. Hogan (140 posts)

It should be back now. I was moving the site and it was down for a bit.

26 Jun 2013, 13:58
Portrait-robert_pragsmall

Robert Dober (20 posts)

Confirmed, thank you.

26 Jun 2013, 15:35
Portrait-robert_pragsmall

Robert Dober (20 posts)

Not sure if this goes better into a suggestion on the errata, pls tell me if you’d prefer that.

Two thoughts on your usage of jQuery in page 33 of pdf version p0

  • Usage of $link for results of jQuery (selector) call.

So link = $(this) would become $link = $(this)

I was wondering if you were aware of that convention and just chose not to follow it for whatever reason (e.g. that it is ugly).

  • Usage of the jQuery data function, so

    $link.attr("data-xxx")

would become

$link.data("xxx")

28 Jun 2013, 00:10
Bphogan_pragsmall

Brian P. Hogan (140 posts)

There’s a note about not using the jQuery .data() function - I need to explain it better though.

While the .data function supports HTML5 attributes, it isn’t really designed around them. For example, it can read them, but it typecasts the data and that’s not always clear. In this case it wouldn’t be an issue, but where people really get in trouble is using the “setter” variant, as it doesn’t write the value back onto the HTML attribute - it merely caches it on the jQuery object. So to keep things simple, I’ve just not used it.

As for prefixing the variables with the $, I personally don’t like that style. I know developers do it, and I know it’s hotly contested, but I haven’t really been a fan of it personally. It’s not a closed issue though. If enough people pressure me into it I might change it.

28 Jun 2013, 07:16
Portrait-robert_pragsmall

Robert Dober (20 posts)

Thx for the explanation Brian. I am not a fan of the $ convention for aesthetic reasons but find the added information useful. I have no strong opinion on this. As for the data function I (i) missed the note (probably because of the small display size of my Samsung but not really an excuse) which is (ii) clear enough I feel for the context (now read on my laptop).

28 Jun 2013, 17:17
Bphogan_pragsmall

Brian P. Hogan (140 posts)

As an update, I actually modified that example to use regular vanilla getAttribute, since there’s really no reason to use jQuery for anything other than the event handler in this case. This should be less confusing and should avoid the discussion entirely.

13 Jul 2013, 09:40
Portrait-robert_pragsmall

Robert Dober (20 posts)

Remarkable you got out from “using a hammer every problem looks like a nail”.

  You must be logged in to comment