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();
if (typeof jQuery.ui == 'undefined') {
// jQuery UI IS NOT loaded, do stuff here.
}
或者
if (typeof jQuery.ui != 'function') {
// jQuery UI IS NOT loaded, do stuff here.
}
或者
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");
}