From 43f7dd2968ab02c3651c58810abf05d8fcd05568 Mon Sep 17 00:00:00 2001 From: appukuttan-shailesh Date: Mon, 2 Dec 2019 15:21:52 +0100 Subject: [PATCH] ellipsis handle hyperlinks --- dataRender/ellipsis.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/dataRender/ellipsis.js b/dataRender/ellipsis.js index 186e9e5..71aa7ce 100644 --- a/dataRender/ellipsis.js +++ b/dataRender/ellipsis.js @@ -72,6 +72,13 @@ jQuery.fn.dataTable.render.ellipsis = function ( cutoff, wordbreak, escapeHtml ) return d; } + var outerTag = false + if (d.includes("href")) { + var wrapper = $(d).clone().empty().prop('outerHTML'); + d = jQuery(d).text(); + outerTag = true + } + var shortened = d.substr(0, cutoff-1); // Find the last white space character in the string @@ -84,6 +91,10 @@ jQuery.fn.dataTable.render.ellipsis = function ( cutoff, wordbreak, escapeHtml ) shortened = esc( shortened ); } - return ''+shortened+'…'; + if (outerTag) { + return $(wrapper).html(''+shortened+'…')[0].outerHTML + } else { + return ''+shortened+'…'; + } }; };