DWilliams Posted January 21, 2011 Share Posted January 21, 2011 I'm not a very good JS developer but I'm muddling my way through creating a nice interface for my program with AJAX and jQueryUI. The AJAX part I have working fine, but I can't seem to get jQueryUI working. I read some of the intros and thought it was pretty simple. I have this in my header: <link type="text/css" href="http://example.com/myfolder/application/assets/css/redmond/jquery-ui-1.8.9.custom.css" rel="Stylesheet" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js"></script> I have verified that all those links work (i changed the actual path to my project to example.com/myfolder but the real one works). In a test page I put: <script> $(function() { $( "#datepicker" ).datepicker({ changeMonth: true, changeYear: true }); }); </script> <div class="demo"> <p>Date: <input type="text" id="datepicker"></p> </div><!-- End demo --> I copied and pasted that from a demo on the jQueryUI website. On their website, when you give focus to the input box, you get a calendar. On my test, nothing at all happens. What gives? It's probably something obvious since I'm so new to jQueryUI Quote Link to comment https://forums.phpfreaks.com/topic/225237-jquery-ui-not-working/ Share on other sites More sharing options...
Maq Posted January 21, 2011 Share Posted January 21, 2011 Have you run this with firebug enabled? It will notify you of errors. Quote Link to comment https://forums.phpfreaks.com/topic/225237-jquery-ui-not-working/#findComment-1163227 Share on other sites More sharing options...
DWilliams Posted January 21, 2011 Author Share Posted January 21, 2011 Firebug reports no JavaScript errors other than: Unexpected token in attribute selector: '!'. I googled that and it's a known issue, or rather a known non-issue. Apparently it doesn't cause problems. There are, however, a bunch of CSS errors. I don't see a way to copy and paste them all at once in Firebug, though. Mostly they seem to be stuff like this: Unknown property 'border-top-left-radius'. Declaration dropped. Which is strange, but even if there are CSS errors then at least SOMETHING should display, right? I'm using firefox 3.6.13 Quote Link to comment https://forums.phpfreaks.com/topic/225237-jquery-ui-not-working/#findComment-1163238 Share on other sites More sharing options...
Maq Posted January 21, 2011 Share Posted January 21, 2011 I just ran your code in firefox and it worked fine. Do you have other code that could be affecting it? Quote Link to comment https://forums.phpfreaks.com/topic/225237-jquery-ui-not-working/#findComment-1163242 Share on other sites More sharing options...
DWilliams Posted January 21, 2011 Author Share Posted January 21, 2011 I just ran your code in firefox and it worked fine. Do you have other code that could be affecting it? Actually yeah I think that might be the problem. I put this in a completely separate file from my project and it worked. After some tinkering it looks like the Prototype JS framework I'm using conflicts with it. If I remove it then the calendar pops up fine. Are these two known to conflict or something? Truth be told I don't even know what Prototype does, I just use it because it's required by the CodeIgniter AJAX library I'm using. If I remove the link to prototype.js then the jQueryUI stuff works, but my AJAX call do not Quote Link to comment https://forums.phpfreaks.com/topic/225237-jquery-ui-not-working/#findComment-1163256 Share on other sites More sharing options...
Maq Posted January 21, 2011 Share Posted January 21, 2011 After some tinkering it looks like the Prototype JS framework I'm using conflicts with it. If I remove it then the calendar pops up fine. Are these two known to conflict or something? Yes there will be a conflict when using 2 separate JS libraries. Read this link: http://docs.jquery.com/Using_jQuery_with_Other_Libraries Basically you will have to call jQuery.noConflict which will override the '$' and allow prototype to use it. For JQuery you will have to use jQuery(...). Quote Link to comment https://forums.phpfreaks.com/topic/225237-jquery-ui-not-working/#findComment-1163261 Share on other sites More sharing options...
DWilliams Posted January 21, 2011 Author Share Posted January 21, 2011 Aha that explains it! I assume I can just change my header to something like this: <link type="text/css" href="http://example.com/myfolder/application/assets/css/redmond/jquery-ui-1.8.9.custom.css" rel="Stylesheet" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js"></script> <script>jQuery.noConflict();</script> And then change $ to jQuery everywhere I try to use it? That header is common to almost all of my pages, the jQuery stuff is pieced together from other sources and dumped into the page (mostly pieces of forms retrieved with AJAX). Quote Link to comment https://forums.phpfreaks.com/topic/225237-jquery-ui-not-working/#findComment-1163265 Share on other sites More sharing options...
Maq Posted January 21, 2011 Share Posted January 21, 2011 Aha that explains it! I assume I can just change my header to something like this: jQuery.noConflict(); And then change $ to jQuery everywhere I try to use it? That header is common to almost all of my pages, the jQuery stuff is pieced together from other sources and dumped into the page (mostly pieces of forms retrieved with AJAX). $ gets changed to jQuery everywhere you're using JQuery. Prototype shouldn't need any changed b/c it is already using. The jQuery.noConflict() just gives up the '$' (which is actually an alias for jQuery) and allows the other libraries to use it. Quote Link to comment https://forums.phpfreaks.com/topic/225237-jquery-ui-not-working/#findComment-1163272 Share on other sites More sharing options...
DWilliams Posted January 21, 2011 Author Share Posted January 21, 2011 Works beautifully now, thanks Quote Link to comment https://forums.phpfreaks.com/topic/225237-jquery-ui-not-working/#findComment-1163283 Share on other sites More sharing options...
Maq Posted January 21, 2011 Share Posted January 21, 2011 Works beautifully now, thanks Np, glad it's working. Quote Link to comment https://forums.phpfreaks.com/topic/225237-jquery-ui-not-working/#findComment-1163285 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.