Hello everyone,
I'm terribly sorry for busting in here without taking the proper time to get acquainted with these forums.
I'm currently in China for a month and during this period I'd like to test Kendo UI, but here in China it's incredibly hard to work on servers outside China.
Many sites are blocked, and the ones which aren't have a very slow connection and sometimes don't work properly (because certain resources are blocked).
That's why it's very frustrating to try to develop something in a new framework; every search for information is so hard... So please forgive me if I'm asking questions which have already been answered.
I'm trying to combine Kendo UI development with a RequireJS based site. But I don't want to use global variables and I want to put the code in a separate module (js-file) instead of the HTML-page. The sample on the Kendo UI site on requirejs didn't help me on that subject.
For some reason I can't get that to work. The Kendo-methods are not defined in the jQuery-object and if I'm trying to use the kendo-object within a define or require method it keeps saying that it's "undefined".
On top of that I'm still in the process of getting used to the use of modules nd requirejs.
Could someone help me out, please?
index.html:
<!DOCTYPE html><html><head> <meta charset="utf-8" /> <title>Testing KendoUI</title> <link rel="stylesheet" href="styles/kendoui/kendo.common-material.min.css" /> <link rel="stylesheet" href="styles/kendoui/kendo.material.min.css" /> <script data-main="js/main" src="js/require.js"></script></head><body> <div id="example"> <div class="demo-section k-content"> <h4>Choose shipping countries:</h4> <input id="countries" style="width: 300px;" /> <div class="demo-hint">Start typing the name of an European country</div> </div> </div></body></html>main.js:
requirejs.config({ paths: { kendo: "ext/kendoui" }});//Start the applicationrequire(["mod/autocomp"], function(pMod){ pMod.StartModule();}); paths: { kendo: "ext/kendoui" }});//Start the applicationrequire(["mod/autocomp"], function(pMod){ pMod.StartModule();});autocomp.js:
define(["jquery", "kendo/kendo.all.min"], function($, pKUI){ var ListItems = [], SetItems = function(pItems) { ListItems = pItems; }, GetItems = function () { return ListItems; }, SetAutoComplete = function(pFieldID) { pKUI.jquery("#" + pFieldID).kendoAutoComplete({ dataSource: ListItems, filter: "startswith", placeholder: "Select country...", separator: ", " }); }, StartModule = function() { SetItems([ "Albania", "Andorra", "Armenia", //... "United Kingdom", "Vatican City"]); //create AutoComplete UI component SetAutoComplete("countries"); }; //Reveal the required methods publicly return { StartModule: StartModule }; });
I tried both "$" and "pKUI.jQuery", $ is defined but doesn't contain any Kendo items, and pKUI just isn't defined at all.