views:

91

answers:

0

How do you implement Twitter Hovercards in GWT PagingScrollTable?

The Hovercard links work fine when, say, I add new Label("@ded") to a HorizontalPanel. However the Twitter JavaScript function doesn't seem to apply when I put "@ded" into a PagingScrollTable row.

I'm a JavaScript newbie.

In response to Igor's request, here's some more details. According to the Twitter docs I put a couple of scripts into the <head> of my HTML file:

<script src="http://platform.twitter.com/anywhere.js?id=myId&amp;v=1"
        type="text/javascript"></script>
<!-- Twitter @Anywhere Hovercards  -->
<script type="text/javascript">
  twttr.anywhere(function (T) {
  T.hovercards();
  });
</script>

Then the Hovercards work as described above, except in a GWT PagingScrollTable. For example, I've implemented an AbstractColumnDefinition whose getCellValue() method returns "@ded". The "@ded" appears in the table, but it doesn't seem to be recognized by the scripts---the "ded" part is not underlined as it is outside the table (the Twitter doc shows an example of working Hovercards).

Looking at it with a web inspector, I see that new Label("@ded") appears as

<div class="gwt-Label">
    "@"
    <a class="twitter-anywhere-user" href="http://twitter.com/ded"&gt;ded&lt;/a&gt;
</div>

but in the last row of my table I see

        <tr style="background:#fafafa;" class>
            <td class>@ded</td>
            <td>...</td>
        </tr>
    </tbody>
</table>

And I've found an error in the logs when I page the table and try to invoke the second script as JSNI, but only when the rows are loaded from cached data:

04:15:51.280 [ERROR] Uncaught exception escaped
com.google.gwt.core.client.JavaScriptException: (ReferenceError): Can't find variable: twttr  
 line: 3  
 sourceId: 4675433328  
 expressionBeginOffset: 209  
 expressionCaretOffset: 214  
 expressionEndOffset: 214   
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:195)    
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120)
    ...