Note that there are some explanatory texts on larger screens.

plurals
  1. POWaiting for DOM to load in JSNI GWT
    primarykey
    data
    text
    <p>I'm currently having a problem where the javascript seems to be executing before the DOM is completely loaded. Why do i say this? Take the following code:</p> <pre><code>var $r = $wnd.Raphael("container", 640, 480); // Creates pie chart at with center at 320, 200, // radius 100 and data: [55, 20, 13, 32, 5, 1, 2] $r.piechart(320, 240, 100, [ 55, 20, 13, 32, 5, 1, 2 ]); </code></pre> <p>returns a Javascript exception: 'f is null'. Which seems to indicate that the container name is not recognized.</p> <p>If specify absolute coordinates the piechart is rendered fine. If i use the previous code in the Chrome console (after all is loaded) it effectively, loads the piechart into the container tag.</p> <p>I've tried wrapping the block of code in a JQuery call:</p> <pre><code>$wnd.jQuery(function($) { // Creates canvas 640 × 480 at 10, 50 var $r = $wnd.Raphael("container", 640, 480); // Creates pie chart at with center at 320, 200, // radius 100 and data: [55, 20, 13, 32, 5, 1, 2] $r.piechart(320, 240, 100, [ 55, 20, 13, 32, 5, 1, 2 ]); }); </code></pre> <p>... And no dice.</p> <p>Any ideias of what i could try?</p> <p>EDIT:</p> <p>Here's how/where i'm calling the JSNI method. The following is the relevant View code.</p> <pre><code>public class WidgetSamplerView extends AbstractPanelView implements WidgetSamplerPresenter.Display { private FlexTable mainPanel; public WidgetSamplerView() { super(); mainPanel = new FlexTable(); HTML container = new HTML(); container.getElement().setAttribute("style", "width:700px;height:700px"); container.getElement().setId("container"); mainPanel.setWidget(0, 1, container); MyRaphaelWrapper.pieChart(); // JSNI Call setWidget(mainPanel); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload