1

I would like to use a javascript library in GWT.

I put the files in the public folder so it is shared between the client and the server and injected the javscript following this tutorial (https://pelle.io/2015/01/27/integrating-javascript-libraries-into-gwt-using-jsni/).

    StyleInjector.inject(INSTANCE.fullcalendarCSS().getText());
    StyleInjector.inject(INSTANCE.fullcalendarPrintCSS().getText());
    StyleInjector.inject(INSTANCE.schedulerCSS().getText());
    ScriptInjector.fromString(INSTANCE.jqueryJS().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject();
    ScriptInjector.fromString(INSTANCE.momentJS().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject();
    ScriptInjector.fromString(INSTANCE.fullcalendarJS().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject();
    ScriptInjector.fromString(INSTANCE.scheduleJS().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject();

Everytime I execute my javscriptcode I get an "not a function" exception.

   public static native void drawScheduler() /*-{

    var calendar = $doc.getElementById("calendar");
    calendar.fullCalendar({
        defaultView: 'timelineMonth',
        events: [
            // events go here
        ],
        resources: [
            // resources go here
        ]
        // other options go here...
    });

}-*/;
1
  • what gwt version are you using? Commented Apr 15, 2016 at 14:04

1 Answer 1

2

Assuming fullCalendar is from a jQuery plugin, then DOM elements aren't modified; you need to wrap it in the jQuery "object" (generally $(calendar), here it'd likely be $win.$(calendar))

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.