Do not use jQuery's attr method to get data-idx attribute.

In some context, it fails inexplicably (the jQuery object is
correctly initialized, the attribute is present); instead
use .get(0).getAttribute().
We could've used .data(), but this seems a better alternative
that lies on things that will not move soon.