Note that there are some explanatory texts on larger screens.

plurals
  1. POSmall bug since jquery 1.4.3
    text
    copied!<p>the recent update to jquery 1.4.3 has introduced a small behavior bug into one of my scripts, and i just cant see what the problem is.</p> <p>The way i use the scripts means i have to use the latest jquery.</p> <p>I think it must be in the onClick function. <a href="http://www.doobox.co.uk/stacks_store/demos/trunky.html" rel="nofollow">The odd behavior introduced can be seen here:</a> And a <a href="http://www.doobox.co.uk/test/test.html" rel="nofollow">test page with console log here</a> when the read more links are clicked for the first time they display instantly, when clicked a second time they reveal in slow animation as they should.</p> <p>The vars i am using equate to:</p> <pre><code> length: %id=truncate%, // 200 minTrail: 0, moreText: "%id=open%", // read more lessText: "%id=close%", // close ellipsisText: "%id=starttrunk%", // ... moreAni: "%id=openspeed%", // slow lessAni: "%id=closespeed%" // slow </code></pre> <p>Here is the script:</p> <pre><code>(function($){ $.fn.jTruncate = function(options) { return this.each(function() { obj = $(this); var body = obj.html(); if(body.length &gt; options.length + options.minTrail) { var splitLocation = body.indexOf(' ', options.length); if(splitLocation != -1) { // truncate tip var splitLocation = body.indexOf(' ', options.length); var str1 = body.substring(0, splitLocation); var str2 = body.substring(splitLocation, body.length - 1); obj.html(str1 + '&lt;span class="truncate_ellipsis"&gt;' + options.ellipsisText + '&lt;/span&gt;' + '&lt;span class="truncate_more"&gt;' + str2 + '&lt;/span&gt;'); obj.find('.truncate_more').css("display", "none"); // insert more link obj.append( '&lt;div class="clearboth"&gt;' + '&lt;a href="#" class="truncate_more_link"&gt;' + options.moreText + '&lt;/a&gt;' + '&lt;/div&gt;' ); // set onclick event for more/less link var moreLink = $('.truncate_more_link', obj); var moreContent = $('.truncate_more', obj); var ellipsis = $('.truncate_ellipsis', obj); moreLink.click(function() { if(moreLink.text() == options.moreText) { moreContent.show(options.moreAni); moreLink.text(options.lessText); ellipsis.css("display", "none"); } else { moreContent.hide(options.lessAni); moreLink.text(options.moreText); ellipsis.css("display", "inline"); } return false; }); } } // end if }); }; })(jQuery); $().ready(function() { $('#%id% .trunky').jTruncate({ length: %id=truncate%, minTrail: 0, moreText: "%id=open%", lessText: "%id=close%", ellipsisText: "%id=starttrunk%", moreAni: "%id=openspeed%", lessAni: "%id=closespeed%" }); }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload