Search code examples
javascriptjqueryjquery-pluginscfml

Jquery.highlight <a> onclick


I have a table on a page that lists users. The initial rendering is a "short list" that only has minimal data. Each row has a plus image and a minus image. The plus image is as follows;

<a href="" onClick='javascript: ColdFusion.navigate("#request.controlurl#calllist/CallListDetail.cfm?UsersID=#CallList.usersID#&callListID=#attributes.callListID#","Ind_#CallList.usersID#");checkKW(); return false;'><img class="plus" src="#request.controlURL#images/plus.gif" border="0"></a>

When the plus icon is clicked I display more detailed data. I want to highlight certain keywords in that data. In the test I'm working on I have 2 rows. When I click on the first plus icon I get the detailed data but without highlighting. When I click on the second row plus icon, the highlighting appears in the first row.

I'm using Jquery highlight js at. The checkKW function is;

function checkKW(){
        $(".commdiv").highlight(document.getElementById('keywordscheckdiv').innerHTML);
        alert('one');
    }

A sample of one of the divs I want to highlight words in is;

<div style="padding:2px 10px 5px 10px; " class="commdiv">
                    <strong>Date:</strong> #dateformat(qCallListComms.Date_Entered,"yyyy/mm/dd")# <strong>Cons:</strong> #qCallListComms.username#
                    <strong>Type:</strong> #qCallListComms.communication_type#&nbsp;&nbsp;&nbsp;#qCallListComms.comment#
                </div>

Solution

  • (From comments ...)

    Check for javascript errors using your browser's debugging tools: Firebug, FF's web console, ... Also, timing might be a factor. You should invoke checkKW after the call succeeds and the div is rendered ie In your callbackHandler.

    That said, any reason you are using ColdFusion.navigate instead of jQuery?