small medium large xlarge

Portrait-robert_pragsmall
24 Jun 2013, 08:42
Robert Dober (20 posts)

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

Bphogan_pragsmall
25 Jun 2013, 19:35
Brian P. Hogan (151 posts)

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

Portrait-robert_pragsmall
26 Jun 2013, 13:58
Robert Dober (20 posts)

Confirmed, thank you.

Portrait-robert_pragsmall
26 Jun 2013, 15:35
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")

Bphogan_pragsmall
28 Jun 2013, 00:10
Brian P. Hogan (151 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.

Portrait-robert_pragsmall
28 Jun 2013, 07:16
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).

Bphogan_pragsmall
28 Jun 2013, 17:17
Brian P. Hogan (151 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.

Portrait-robert_pragsmall
13 Jul 2013, 09:40
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