console. log("not loaded"); If the above code writes “loaded” on console window, that means jQueryUI is loaded.
You can use $. ui. version , it's actually the property jQuery UI looks for when determining if it should load itself (if it's already there, abort).
In general, you just use the following basic "document loaded" test in jquery. Straight from the beginners jquery tutorial: $(document). ready(function() { // do stuff when DOM is ready });
Press F12. Go to console. Type jQuery and press enter. In case, your app is not using jQuery, then you'll get error.
if (jQuery.ui) {
// UI loaded
}
OR
if (typeof jQuery.ui != 'undefined') {
// UI loaded
}
Should do the trick
You need to check if both, the jQuery UI Library file and CSS Theme are being loaded.
jQuery UI creates properties on the jQuery object, you could check:
jQuery.ui
jQuery.ui.version
To check if the necessary CSS file(s) are loaded, I would recommend you to use Firebug, and look for the theme files on the CSS tab.
I've seen problems before, when users load correctly the jQuery UI library but the CSS theme is missing.
I know this is an old question, but here is a quick little script you can use to wrap all your jQuery UI things that don't have an associated event to make sure they get executed only after jQuery UI is loaded:
function checkJqueryUI() {
if (typeof jQuery.ui != 'undefined') {
do_jqueryui();
}
else {
window.setTimeout( checkJqueryUI, 50 );
}
}
// Put all your jQuery UI stuff in this function
function do_jqueryui() {
// Example:
$( "#yourId" ).dialog();
}
checkJqueryUI();
Just test for the ui object, e.g.
<script src="jquery.js"></script>
<script src="jquery-ui.js"></script>
<script>
$(function(){
// did the UI load?
console.log(jQuery.ui);
});
</script>
You can check if jQuery UI is loaded or not by many ways such as:
if (typeof jQuery.ui == 'undefined') {
// jQuery UI IS NOT loaded, do stuff here.
}
OR
if (typeof jQuery.ui != 'function') {
// jQuery UI IS NOT loaded, do stuff here.
}
OR
if (jQuery.ui) {
// This will throw an error in STRICT MODE if jQuery UI is not loaded, so don't use if using strict mode
alert("jquery UI is loaded");
} else {
alert("Not loaded");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With