jQuery - Using SimpleToolTip Plugin
<p>I am using jQuery along with the Simple Tooltip plugin. ( <a href="http://dev.mariusilie.net/content/simple-tooltip-jquery-plugin" rel="nofollow">http://dev.mariusilie.net/content/simple-tooltip-jquery-plugin</a>) </p>

<p>I have a function that loops through the cells of a table, checks to see if there is a match and then sets the title element and then calls the simple tooltip plugin. </p>

<p>This works perfectly when the page initially loads. The problem occurs when I try to change the title element without reloading the whole page. I can confirm that the title element for the cell does get updated but inspecting it using chrome but the tooltip still displays the old values when the mouse hovers over the cell.</p>

<p>I am quite sure this is a fundamental part of jQuery that I am just misunderstanding. Any input would be greatly appreciated.  </p>

<p>EDIT: Ok I think I see whats going on although I dont know how to resolve it. Ever time I call $(cell).simpletooltip();  it adds the .hover to that element. I am guessing that each subsequent call to it for an element that already has the .hove attached is either failing or is adding it but the first one is still there and is the one that is triggered when the mouse hovers. Seems like I need to remove that first function..</p>

<p>This is the Simple Tool Tip plugin:</p>

<pre><code>/**
*
*   simpleTooltip jQuery plugin, by Marius ILIE
*   visit http://dev.mariusilie.net for details
*
**/
(function($){ $.fn.simpletooltip = function(){
    return this.each(function() {
        var text = $(this).attr("title");
        $(this).attr("title", "");
        if(text != undefined) {
        $(this).hover(function(e){
            var tipX = e.pageX + 12;
            var tipY = e.pageY + 12;
            $(this).attr("title", ""); 
            $("body").append("&lt;div id='simpleTooltip' style='position: absolute; z-index: 100; display: none;'&gt;" + text + "&lt;/div&gt;");
            if($.browser.msie) var tipWidth = $("#simpleTooltip").outerWidth(true)
            else var tipWidth = $("#simpleTooltip").width()
            $("#simpleTooltip").width(tipWidth);
            $("#simpleTooltip").css("left", tipX).css("top", tipY).fadeIn("medium");
        }, function(){
            $("#simpleTooltip").remove();
            $(this).attr("title", text);
        });
        $(this).mousemove(function(e){
            var tipX = e.pageX + 12;
            var tipY = e.pageY + 12;
            var tipWidth = $("#simpleTooltip").outerWidth(true);
            var tipHeight = $("#simpleTooltip").outerHeight(true);
            if(tipX + tipWidth &gt; $(window).scrollLeft() + $(window).width()) tipX = e.pageX - tipWidth;
            if($(window).height()+$(window).scrollTop() &lt; tipY + tipHeight) tipY = e.pageY - tipHeight;
            $("#simpleTooltip").css("left", tipX).css("top", tipY).fadeIn("medium");
        });
    }
});
}})(jQuery);
</code></pre>

<p>Below is my code:</p>

<pre><code> // Iterate over each cell for the day and assign a category css class to each.
    $('table.tstat_program_hours td[data-day=' + dayOfWeek + ']').each(function(index, elem) {
        var cell = $(this);
        var cellHour = cell.attr('data-hour');

        var tempTitleInLoop = '';

        if (cellHour &lt; data['wake_time']) {
            tempTitleInLoop = 'Night';
            cell.attr('title',tempTitleInLoop);
        }   

        /* set the wake */
        if(cellHour &lt; data['morning_time']&amp;&amp;cellHour &gt;= data['wake_time']) {
            tempTitleInLoop = 'Wake';
            cell.attr('title',tempTitleInLoop);
        }

        /* set the morn */
        if(cellHour &lt; data['evening_time']&amp;&amp;cellHour &gt;= data['morning_time']) {
            tempTitleInLoop = 'Day';
            cell.attr('title',tempTitleInLoop);
        }

        /* set the evening */
        if(cellHour &lt; data['night_time']&amp;&amp;cellHour &gt;= data['evening_time']) {
            tempTitleInLoop = 'Eve';
            cell.attr('title',tempTitleInLoop);

        }

        /* set the night */
        if(cellHour &gt;= data['night_time']) {
            tempTitleInLoop = 'Night again';
            cell.attr('title',tempTitleInLoop);
        }



        $(cell).simpletooltip();
</code></pre>
