The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Thanks, Mark. I suspected as much. I just wanted to see if I was missing anything dumb (as I've been known to). I appreciate your quick response.
Section 3.1.6 tells us that we should be able to pass a function as the second argument to the .data() wrapper method and doing so will cause it to be called for each element in the wrapped set. However, when I try the following on a page that consists of an unordered list with a dozen or so items it does not work.

$(function () {
$('li').data('data-custom', function () {
return $(this).text();
});

/* separated for clarity */
$('li').click(function () {
alert($(this).data('data-custom'))
})
});

Instead of displaying the text of the clicked-on list item, the alert dialog contains the text of the function as follows:

function () {
return $(this).text();

What gives? I've fought with this for a while now. I can get exactly the behavior I want with the following code, but the book clearly states the above should work.

$('li').each(function (i) {
$(this).data('data-joe', $(this).text())
}).click(function () {
alert($(this).data('data-joe'));
})

Thanks for any insight!