Hello.
I'm trying to create a Show All Text / Shorten Text button in my Sencha Touch app that, when "Shorten Text" is clicked shortens the text on screen. Then, when clicked a second time, the button will read "Show All Text" and all the text that was shortened will be displayed again.
I can get the shorten part to work just fine using Ext.util.Format.ellipsis(), but I can't get my original text back. Consider the following example:
Code:
if (btn.getText() === "Show All Text") {
for (var i=0, max=ratingDesc.elements.length; i < max; i++) {
if (ratingDesc.elements[i].dom.childNodes[0]) {
ratingDesc.elements[i].dom.childNodes[0].data = ratingDesc.elements[i].dom.childNodes[0].data;
}
}
this.getShowAllTextBtn().setText("Shorten Text");
} else {
for (var i=0, max=ratingDesc.elements.length; i < max; i++) {
if (ratingDesc.elements[i].dom.childNodes[0]) {
ratingDesc.elements[i].dom.childNodes[0].data = Ext.util.Format.ellipsis(ratingDesc.elements[i].dom.childNodes[0].data, 25, true);
}
}
this.getShowAllTextBtn().setText("Show All Text");
}
Thanks in advance.