This is a migrated thread and some comments may be shown as answers.

Kendo UI & RequireJS: x is not a function, although Kendo is loaded

2 Answers 198 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Stefan
Top achievements
Rank 1
Stefan asked on 06 Jun 2016, 09:34 AM

Hello,

 

I use RequireJS to load Kendo according to a post in StackOverflow (http://stackoverflow.com/questions/18671338/inject-kendo-ui-with-requirejs) and it works. jQuery is loaded first, then Kendo. But I got an error "kendoButton is not a function" (applies to all Kendo UI components, but here I use kendoButton as an example). Here is my app.js.

require.config({
    paths: {
        "jquery": "lib/kendo-ui/jquery.min",
        "jquery-ui": "lib/jquery-ui.min",
        "kendo-ui": "lib/kendo-ui" // this is a directory containing all Kendo files
    },
    shim: {
        "kendo-ui/kendo.button.min": {
            deps: ["jquery"]
        },
        "kendo-ui/kendo.core.min": {
            deps: ["jquery"]
        }
    }
});

require(["jquery", "kendo-ui/kendo.core.min", "kendo-ui/kendo.button.min"],
function ($)
{
    $("#primaryTextButton").kendoButton();
});

Kendo troubleshooting says that jQuery should be included just once (yes, I have) and all the required Kendo files are included (yes, I included kendo.core.min.js).

I use RequireJS 2.2.0, Kendo 2016.1.226, and jQuery version, which is included in the Kendo package. Can someone point out what's wrong?

Thanks and regards,

Stefan

2 Answers, 1 is accepted

Sort by
0
Stefan
Top achievements
Rank 1
answered on 06 Jun 2016, 11:04 AM
I just read a post by Peter and found the solution: Set the baseURL to "js/kendo".
I'm not sure if this has been stated clearly in the documentation. I thought the URL in the example is well, an example, but it turns out to be important.
0
Petyo
Telerik team
answered on 08 Jun 2016, 06:46 AM
Hello,

the baseUrl is important, indeed. Worth mentioning is that if you start a project now, you may give the NPM packages a try. 

Regards,
Petyo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
General Discussions
Asked by
Stefan
Top achievements
Rank 1
Answers by
Stefan
Top achievements
Rank 1
Petyo
Telerik team
Share this question
or