jQuery UI加载事件? [英] JQuery UI Loaded Event?
问题描述
无论如何,是否不仅可以检测到jquery UI已加载,还可以在触发时触发事件?现在,我已经将代码包装在$(document).ready()函数中,但是有时UI代码会出错,因为UI库没有完全加载(一切都以正确的顺序加载).该代码可在99%的时间内正常工作,但大约有1%的用户会收到与未加载UI有关的javascript错误.
Is there anyway to not only detect that the jquery UI loaded but also fire an event when it does? Right now I have code wrapped in a $(document).ready() function but sometimes the UI code errors out because the UI library did not fully load (everything is loading in the correct order). The code works 99% of the time but about 1% of the users get a javascript error related to the UI not loading.
类似
$(document).ready(function() {
jQuery.ui.ready(function() { ....
像这样可能吗?
谢谢.
推荐答案
您可以尝试使用getcript加载jQuery-ui等插件,并在脚本完全加载之前保留ready函数.
You could try to load your plugin like jQuery-ui and other with getcript and hold the ready function(s) before the script is fully loaded
// Hold the ready function(s)
$.holdReady(true);
// Retrieve the script and unlock the ready function(s) when the script is loaded
$.getScript("myplugin.js", function() {
$.holdReady(false);
});
使您准备就绪的功能变得简单
Keeping you ready function(s) simple
$(document).ready(function() {
// your code here
});
这篇关于jQuery UI加载事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!