Injecting JavaScript(JSNI) to Cell Table DOM

51 views
Skip to first unread message

Abdullah

unread,
Apr 1, 2015, 12:22:36 PM4/1/15
to google-we...@googlegroups.com
Hi,
In my application i am using GWT Cell Table, for some of the Column Header i want to add tooltip.Column Header is created by using SafeHtml and Injecting JS to cell table header using JSNI. But that time the DOM is not creating and JavaScript is not attaching to the column Header for tooltip.If i use Timer then the Problem is goes off,I don't want to use Timer.Is there any Way to inject JS?Any Clue?See below code,

Column Header SafeHtml:
SafeHtml="<span>Total</span><span title='' rel='tooltipTop' class='reqFull' data-original-title='{0}'> <i class='fa fa-info-circle'></i></span>";

JSNI:
 private static native void initTooltip() /*-{
    $wnd.$(document).ready(function(){
    $wnd.jQuery("[rel=tooltipTop]").tooltip({ placement: 'top'});
    });
    
    }-*/;

I am Calling this JSNI after the table creation but still DOM is not ready.
Even i tried calling this JSNI Script in onAttach() Method,

@Override
protected void onAttach() {
super.onAttach();
initTooltip();
}

Any Suggestion?

Frank Taffelt

unread,
Apr 2, 2015, 4:05:04 AM4/2/15
to google-we...@googlegroups.com
can you try:
$wnd.$($doc).ready(

function(){
    $wnd
.jQuery("[rel=tooltipTop]").tooltip({ placement: 'top'});
   
});


or skip the ready block your dom is already there...

Abdullah

unread,
Apr 4, 2015, 1:27:29 AM4/4/15
to google-we...@googlegroups.com

Hi Frank,
Thanks for your suggestion..

I added this in Scheduler

Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
initTooltip();
}
});
This Works for me..
can you try:
$wnd.$($doc).ready(

function(){

    $wnd
.jQuery("[rel=tooltipTop]").tooltip({ placement: 'top'});
    
});
Reply all
Reply to author
Forward
0 new messages