Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > DatePicker problem View modes: 
User avatar
Member
Member
nanite2000 - 4/2/2013 2:53:22 PM
   
DatePicker problem
HI,

I'm using Kentico v7.0.26.

I've created a registration form using System Settings -> Development -> System Tables -> User -> Alternative Forms.

One of the registration fields is 'Date Of Birth' and uses a DatePicker control.

Every time I click on the DatePicker icon on the rendered form, I get a javascript error:
Uncaught TypeError: Cannot read property 'mozilla' of undefined

The error is thrown by '~CMSScripts/JQuery/jquery-ui-datetimepicker.js', and it looks like JQuery is not being recognised in that script (likely because there are other JQuery controls on the page).

How can I change the behaviour of this script so it doesn't conflict with other controls?

Thanks.

User avatar
Member
Member
kentico_sandroj - 4/2/2013 4:57:35 PM
   
RE:DatePicker problem
Hello,

Could you please try using <script>jQuery.noConflict();</script> after your script to see if it resolves the issue? There is a knowledge base article on this topic: KB Article

Additionally, there is documentation on the jQuery site that may be helpful: jQuery Documentation

Good luck and let me know how it turns out.

Best Regards,
Sandro Jankovic

User avatar
Member
Member
nanite2000 - 4/2/2013 10:37:01 PM
   
RE:DatePicker problem
kentico_sandroj wrote: Hello,

Could you please try using <script>jQuery.noConflict();</script> after your script to see if it resolves the issue? There is a knowledge base article on this topic: KB Article

Hi Sandro,

I've tried adding NoConflict to all the scripts I can find on that page, but I still get the same problem.

I am using dozens of different scripts on my pages, both inline and from downloaded libraries. I may have missed one...but it's hard to tell.

Given that Kentico utilises so many JQuery libraries, and given that developers are *highly* likely to use their own JQuery libraries quite frequently, can you tell me why Kentico don't actually use NoConflict in their own scripts?

Thanks.

User avatar
Member
Member
nanite2000 - 4/4/2013 10:43:38 PM
   
RE:DatePicker problem
Can anyone help?

User avatar
Kentico Consulting
Kentico Consulting
richards@kentico.com - 4/5/2013 2:05:07 AM
   
RE:DatePicker problem
Hi,

Unfortunately not every issue may be solved by using the noConflict mode. Since this datepicker is a build-in functionality and is using the standart jquery ui it should work. My question would be what libraries are you using, where and why? Also I would strongly recommend you to use Firebug Addon and see if there are more information regarding loading libriaries etc..

If it doesn not help in any way than there is one more thing to do - loop through all your custom libraries, removing them and checking which one is exactly causig this issue. When you know the exact source of this error you may do something about it (like choosing a different addon).

Kind regards,
Richard Sustek

User avatar
Member
Member
nanite2000 - 4/7/2013 3:36:37 PM
   
RE:DatePicker problem
richards@kentico.com wrote: If it doesn not help in any way than there is one more thing to do - loop through all your custom libraries, removing them and checking which one is exactly causig this issue. When you know the exact source of this error you may do something about it (like choosing a different addon).

I did that, and the source of the problem is an external library we are including in our Master template:

http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.9.1.min.js

Because this file is hosted externally, we cannot insert the NoConflict() statement into it. We also need it.

You may ask why we don't just use the JQuery library shipped with Kentico, but that library is out of date (v1.7.2, as opposed to v1.9.1 that we wish to use).

So, how can we handle externally referenced libraries where inserting the NoConflict command is not an option?

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 4/8/2013 1:08:27 AM
   
RE:DatePicker problem
Hello,

As first, let me note, that jQuery 1.9 is not officially supported, and it's causing problems because they have changed some API methods, so it's not back-ward compatible in all ways. We can not handle this because it was released a few months after Kentico 7. I would recommend you to use the jQuery 1.8.x in the NoCoflict mode or take a look at the KB article provided by Sandro. You don't have to modify any jQuery library, just the call of the methods from that library.

Btw... if the v1.7.2 is from your point of view so old, is there something that you are missing related to the latest version? :)

Best regards,
Martin Danko

User avatar
Member
Member
nanite2000 - 4/8/2013 10:08:05 PM
   
RE:DatePicker problem
kentico_martind2 wrote: Btw... if the v1.7.2 is from your point of view so old, is there something that you are missing related to the latest version? :)

Best regards,
Martin Danko

It's not so much the fact that v1.7.2 is out of date, so much as the fact that our front-end developer has created pages that use the v1.9.* syntax and API's.

As you say, the API has changed in some areas, so something written for v1.9.* may not be backward compatible with v1.7.2.

User avatar
Member
Member
nanite2000 - 4/9/2013 6:14:52 PM
   
RE:DatePicker problem
kentico_martind2 wrote: Btw... if the v1.7.2 is from your point of view so old, is there something that you are missing related to the latest version? :)

Best regards,
Martin Danko

I reference my JQuery libraries in the customizable <head> portion of my master page. These JQuery references are being rendered *before* the default Kentico JQuery library is referenced, causing them to all break.

How can I get around this?

User avatar
Certified Developer 13
Certified Developer 13
kentico-jx2tech - 4/9/2013 6:34:09 PM
   
RE:DatePicker problem
You might want to try this solution: Using multiple versions of jQuery

User avatar
Member
Member
nanite2000 - 4/9/2013 10:32:14 PM
   
RE:DatePicker problem
kentico-jx2tech wrote: You might want to try this solution: Using multiple versions of jQuery

That's no good if you are referencing external JQuery libraries (as we are), since you cannot tell them what your preferred JQuery syntax is.

As if that wasn't bad enough, Kentico's built in JQuery library is not loaded for all pages. So I cannot always guarantee it will be there.

I would gladly use the Kentico JQuery library if there was a way of always ensuring it is available to all pages.

Does anyone know how this can be done?

User avatar
Member
Member
nanite2000 - 4/9/2013 10:49:38 PM
   
RE:DatePicker problem
I just answered my own question.

Look in the source code of a page that contains conflicting jquery references. Kentico's is referenced with:
<script src="~/CMSPages/GetResource.ashx?scriptfile=%7e%2fCMSScripts%2fjquery%2fjquery-core.js" type="text/javascript"></script>

(in v7.0.26)

Add a copy to this reference in your Master Page. It doesn't matter if the browser loads it twice since it's cached.

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 4/9/2013 10:59:46 PM
   
RE:DatePicker problem
nanite2000 wrote: As if that wasn't bad enough, Kentico's built in JQuery library is not loaded for all pages. So I cannot always guarantee it will be there.

I would gladly use the Kentico JQuery library if there was a way of always ensuring it is available to all pages.

Does anyone know how this can be done?
Take a look at this KB Article. I spent a few hours struggling with last week but it shows you how to include it on every page. Also note, it will include the jQuery.UI library and you have the option to exclude the css (this.Page, false).