Dotdotdot.js after and callback features - can't hide a link

Dotdotdot.js after and callback features - can't hide a link

Greetings,

I'm trying to use dotdotdot.js to ellipsis-truncate text in divs and other containers.  Using dotdotdot I can specify a container I want to receive ellipsis-truncation:
  1.   $(document).ready(function() {
  2.       $(".truncated_box").dotdotdot({
  3.           after: "a.readMoreLink",
  4.           callback: hideLinkIfNoTruncation
  5.       });
  6.   });
dotdotdot will truncate text inside containers with class truncated_box, and add an ellipsis and a link with the class readMoreLink.  However, a.readMoreLink must initially be inside the container, like this:
  1.   <div class="truncated_box">
  2.     This is a rather lengthy text inside a div. This is a rather lengthy text inside a div. This is a rather lengthy text inside a div.
  3.      <a href="#" class="readMoreLink" onclick="clicked()">Read More</a>
  4.   </div>
The given callback is called whenever a container with the given class is considered for truncation (regardless of whether truncation occurs or not).  So I wrote this callback so ensure that if a container is considered for truncation but not truncated the 'read more' link will be hidden:
  1.     function hideLinkIfNoTruncation(isTruncated, origContent) {
  2.     if (!isTruncated) {
  3.     var shouldBeAnAnchor = origContent.filter('a')
  4.     shouldBeAnAnchor.hide()
  5.     }
  6.     }
The hide call has no effect.  If I debug I see that origContent.filter('a') does return the <a> object.  What is wrong with my code?  Bottom line is,  I only want the 'read more' link to show if truncation actually happens!

If anyone can help, thanks.  I've attached a zipfile with my HTML plus jquery and dotdotdot.js.  Also, here is all the code from my HTML page:
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  4. <meta charset="utf-8">
  5. <title>Dot Dot Dot - Does it Work?</title>
  6. <script src="js/jquery-1.8.3.js" type="text/javascript"></script>
  7. <script src="js/jquery.dotdotdot-1.5.2.js" type="text/javascript"></script>
  8. <script type="text/javascript">

  9.     function hideLinkIfNoTruncation(isTruncated, origContent) {
  10.     if (!isTruncated) {
  11.     var shouldBeAnAnchor = origContent.filter('a')
  12.     shouldBeAnAnchor.hide()
  13.     }
  14.     }

  15.   $(document).ready(function() {
  16.       $(".truncated_box").dotdotdot({
  17.           after: "a.readMoreLink",
  18.           callback: hideLinkIfNoTruncation
  19.       });
  20.   });

  21. function clicked() {
  22. alert("Link was clicked.");
  23. }

  24. </script>

  25.   <style>
  26.   div.truncated_box {
  27.     height: 135px;
  28.     width: 350px;
  29.     font-size: 18px;
  30.     margin: 5px;
  31.     padding: 3px;
  32.     border-style: solid;
  33.     border-width: 3px;
  34.     border-color: red;
  35. }
  36. </style>
  37. </head>
  38. <body>
  39. <h1>Three Dots</h1>
  40.   <h3>Ellipses and Read More Link</h3>

  41.   <div class="truncated_box">
  42.     This is a rather lengthy text inside a div. This is a rather lengthy text inside a div. This is a rather lengthy text inside a div. This is a rather lengthy text inside a div. This is a rather lengthy text inside a div. This is a rather lengthy text inside a div.
  43.     This is a rather lengthy text inside a div. This is a rather lengthy text inside a div. This is a rather lengthy text inside a div. This is a rather lengthy text inside a div. This is a rather lengthy text inside a div. This is a rather lengthy text inside a div.
  44.     This is a rather lengthy text inside a div. This is a rather lengthy text inside a div. This is a rather lengthy text inside a div. This is a rather lengthy text inside a div. This is a rather lengthy text inside a div. This is a rather lengthy text inside a div.
  45.     <a href="#" class="readMoreLink" onclick="clicked()">Read More</a>
  46.   </div>

  47.   <div class="truncated_box">
  48.     This is a rather lengthy text inside a div. This is a rather lengthy text inside a div. This is a rather lengthy text inside a div.
  49.      <a href="#" class="readMoreLink" onclick="clicked()">Read More</a>
  50.   </div>

  51.   <div class="truncated_box">
  52.     This is a rather lengthy text inside a div. This is a rather lengthy text inside a div. This is a rather lengthy text inside a div. This is a rather lengthy text inside a div. This is a rather lengthy text inside a div. This is a rather lengthy text inside a div.
  53.      <a href="#" class="readMoreLink" onclick="clicked()">Read More</a>
  54.   </div>
  55. </body>
  56. </html>