c# - MVC Razor view: Minify text with three dots and show full text with tooltip -


i have following code display dots @ end of string if longer limit. want display tooltip full text on hover. not sure how implement razor view element.

@(item.data.title.length > 10 ? item.data.title.substring(0, 10) + "..." : item.data.title) 

you can implement tooltip via jquery , bootstrap following.

jsfiddle example : https://jsfiddle.net/z4upto60/

cshtml:

<div>      <a data-toggle="tooltip" title="@item.data.title">         @(item.data.title.length > 10 ? item.data.title.substring(0, 10) + "..." : item.data.title)     </a> </div> 

jquery:

if('@item.data.title.length' > 10) {    $('a[data-toggle="tooltip"]').tooltip({       animated: 'fade',       placement: 'bottom',    }); } 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -