Combining jQuery Truncation and clueTip Plugins in ASP.NET ListView

by Bill Beckelman 19. October 2008 21:35

I tried combining the jQuery truncation plugin that I found a while back with the jQuery clueTip plugin that I posted about several weeks ago to improve the display of data in an ASP.NET ListView.

Demo | Download

End Product:

image

I had some trouble getting the two plugins to work together. I initially tried adding a ToolTip to the label containing the note, but things just didn't work.  I suspect one or the other isn't properly constructed, but I am not really sure. I haven't learned how to write jQuery plugins yet so it is only an assumption which could certainly be wrong and I might be missing something.

I was able to get things to work by not including the ToolTip or title on the label, but instead on the cell that contains the note. This has the advantage that the clueTip appears whenever the user's mouse is in the cell and not just when over the text.

HTML:

<td title='<%# Eval("contactname") + " Note|" + Eval("note") %>' class="noteTD">
    <asp:Label ID="Label1" runat="server" Text='<%# Eval("note") %>' CssClass="note"></asp:Label>
</td>

jQuery:

<script type="text/javascript">
    $(document).ready(function() {
        $('.noteTD').cluetip({ splitTitle: '|', width: 300, cursor: 'pointer', sticky: false });
        $('.note').truncate({ max_length: 50 });
    });         
</script>

If anyone figures out why the two plugins don't play nice, please let me know in the comments.

kick it on DotNetKicks.com     

Tags:

ASP.NET | jQuery

Comments

Comments are closed

Powered by BlogEngine.NET 1.4.5.7
Theme by Mads Kristensen


About Me

I live and work in Salt Lake City, Utah. My background is in aviation. I have a degree in Aeronautical Science from Embry-Riddle Aeronautical University in Prescott, AZ. I have worked as a commercial airline pilot and most recently as a technical advisor for a charter airline.