Advertisement
Ortund

Untitled

Feb 22nd, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.61 KB | None | 0 0
  1.     <td class="long-data">
  2.         <span class="tooltip">16 This Street Avenue, That Suburb, Some City, 1000</span>
  3.     </td>
  4.     <script>
  5.         // shorten data and display the full content as a tooltip
  6.         // code based on this JSFiddle http://jsfiddle.net/Handyman/fNjFF/11/
  7.         var longdatacellvalue;
  8.         $(document).on("ready", function () {
  9.             var longdatacell = $("td.long-data");
  10.             longdatacellvalue = longdatacell.html();
  11.  
  12.             // shorten data to 20 characters long
  13.             longdatacell.html(longdatacellvalue.substring(0, 20));
  14.             $(".tooltip").attr("title", longdatacellvalue);
  15.         });
  16.  
  17.         $(".long-data").tooltip({ // errors here "Object doesn't support this property or method"
  18.             items: 'span.tooltip',
  19.             content: longdatacellvalue,
  20.             show: null,
  21.             open: function (event, ui) {
  22.                 if (typeof (event.originalEvent) === "undefined") {
  23.                     return false;
  24.                 }
  25.  
  26.                 var $id = $(ui.tooltip).attr("id");
  27.  
  28.                 // close any lingering tooltips
  29.                 $("div.ui-tooltip").not("#" + $id).remove(); // don't know where this div comes from?
  30.             },
  31.             close: function (event, ui) {
  32.                 ui.tooltip.hover(function () {
  33.                     $(this).stop(true).fadeTo(400, 1);
  34.                 },
  35.                 function () {
  36.                     $(this).fadeOut("400", function () {
  37.                         $(this).remove();
  38.                     });
  39.                 });
  40.             }
  41.         });
  42.     </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement