0

I has knockout custom binding and use "dotdotdot" into it.

ko.bindingHandlers.dotdotdot =
{
init: function (element, valueAccessor, allBindingsAccessor) {
      var value = ko.utils.unwrapObservable(valueAccessor());
      $(element).text(value);
      setTimeout(function () {
          $(element).dotdotdot({ wrap: 'letter', fallbackToLetter: 'letter', 
          watch: 'window' });
          }, 300);
      },
update: function (element, valueAccessor, allBindingsAccessor) {
      var value = ko.utils.unwrapObservable(valueAccessor());
      $(element).text(value);
      setTimeout(function () {
      $(element).dotdotdot({ wrap: 'letter', fallbackToLetter: 'letter', 
      watch: 'window' });
         }, 300);
      }
};

I use this binding like this

<table>
 <tr>
 ....
  <td>
     <span data-bind="dotdotdot: TeamMemberName ">
  </td>
</tr>
</table>

where self.TeamMemberName = ko.observable(data.TeamMemberName);

After page loaded "dotdotdot" completely removes all content and column becomes empty. I try to use "height" property with span, but it doesn't work. What I do wrong?

  • What version of dotdotdot are you using? I don't see support for the options you're passing to it in the latest version. There's no "wrap" or "fallbackToLetter" that I can find. – Jason Spake Oct 06 '17 at 16:31
  • You don't need to bind `$(element).dotdotdot()` inside `update`. – adiga Oct 06 '17 at 18:40
  • @JasonSpake, I use version 1.8.1 – Andrey-T Oct 07 '17 at 04:19
  • @adiga, I remove dotdotdot from update function, so it contains only this: var value = ko.utils.unwrapObservable(valueAccessor()); $(element).text(value); . RESULT - https://www.screencast.com/t/sXQgprNN. Only long string is displayed. Short strings are hidden. I change span to div and result becomes - https://www.screencast.com/t/XEXZZ4jHl . It displays data but it is not truncated. Also, o try to use "height" property to div, but content is removing. – Andrey-T Oct 07 '17 at 04:33
  • @JasonSpake, also I removed all options so calling is $(element).dotdotdot({}). – Andrey-T Oct 07 '17 at 04:40
  • @Andrey-T can you create a fiddle? [I can't get the dotodotdot to work](https://jsfiddle.net/adigas/v161fkzn/4/) – adiga Oct 07 '17 at 08:36
  • I created the fiddle - https://jsfiddle.net/defmindat/tj8ezdmm/4/ . It works but only with version 2.0.1. I have noticed that dotdotdot with version > 2.0.1 not working. Also if you use span instead of div then content is removed. And you need have height restrictions (height: ...) to div because height restrictions of is not working – Andrey-T Oct 08 '17 at 16:31

0 Answers0