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

Force jQuery.noConflict on generated code

3 Answers 273 Views
General Disccussions
This is a migrated thread and some comments may be shown as answers.
MARTIJN
Top achievements
Rank 1
MARTIJN asked on 20 Dec 2017, 09:41 AM

I am using PHP wrapper to generate a Kendo UI Grid. But the view factory that I am using use jQuery and other stuff (doesn't matter). So, when I try it to generate a page in the application and add the code that generates Kendo UI Grid. The browser fires an exception because 'jQuery' object doesn't exist. I tried jQuery. (https://api.jquery.com/jquery.noconflict/) API but it didn't work.

Is there an option in Kendo UI wrappers to the symbol or the name that it should use for jQuery?

3 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 22 Dec 2017, 07:42 AM
Hello,

You should be able to change the jQuery alias by using $.noConflict() as follows:
<script>
  $m = jQuery.noConflict();
  $m("#combo").kendoComboBox({});
</script>

Also, please make sure that jQuery is referenced only once and that it is placed in the <head> element of the page along with the kendo scripts. Failing to do so might result in undefined widgets error. You can checkout the Troubleshooting Documentation Article, where you can find more about the most common issues that can be encountered and different ways to solve them.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
MARTIJN
Top achievements
Rank 1
answered on 23 Dec 2017, 10:01 AM
Thank you, I know this part. But I am using PHP wrappers to generate the widgets. So the noConflict method won't work. I tried it before I asked the question. The page that I am working on is working great. But after the integration with Moodle page renderer, it reports that jQuery doesn't exist or not defined. I reference jquery the same page and it will be called before the kendo UI min js file in the page so I don't think it's a reference issue. The additionals configurations like the custom filter don't have any errors, only the generated code does.
0
Dimitar
Telerik team
answered on 26 Dec 2017, 09:28 AM
Hello,

The server-side wrappers for the Kendo UI widgets are self-initialized. This means that each initialization script is rendered right after the HTML markup of the widget. In such cases, the Kendo UI scripts can be registered at the end of the document while the jQuery script must be registered in the body before the first Kendo UI widget on the document, or in the document head.

I have made a quick research on the moodle renderer and noticed that it forces all script tags at the end of the body of the page. Therefore, in case jQuery is loaded by default with the moodle renderer, you should move the reference to the <head> of the page and make sure that jQuery is referenced only once in the page, otherwise all existing jQuery plugins (including Kendo UI) will be wiped out, thus triggering an error.

Please refer to the following documentation in moodle for using jQuery:


Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
General Disccussions
Asked by
MARTIJN
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
MARTIJN
Top achievements
Rank 1
Share this question
or