我使用yepnope.js但與負載在磁頭裝載功能是的/沒了用的document.ready
輕微的問題,我有是的沒有耶,並作出相關的js調用文件
<script type="text/javascript" src="/code/trunk/javascript/external/modernizr/modernizr-development.js"></script>
<script type="text/javascript" src="/code/trunk/javascript/external/yepnope.1.5.3-min.js"></script>
<script type="text/javascript">
yepnope({
test: Modernizr.mq('only all and (max-width: 700px)'),
yep: ['/templates/client/jquery/qff/plugin.mobile.js'],
nope:['/templates/client/jquery/qff/plugin.website.js']
});
</script>
,然後在頁面
<script type="text/javascript">
jQuery(document).ready(function()
{
jQuery("#mainContent").setupQantas({
startSlide: 1,
googleAnalytics:1,
googleCode:""
});
});
</script>
的底部,所以我在主屏幕上看着這一點。所以它suppoed在plugin.mobile.js調用
在plugin.mobile.js文件
(function($){
$.fn.setupQantas = function(options) {
// Create some defaults, extending them with any options that were provided
var settings = $.extend({
startSlide: 1,
googleAnalytics:0, // 1 sends to google
googleCode: ""
}, options);
var methods = {};
return this.each(function() {
if (settings.startSlide === 1) {
alert("slide = 1");
} else {
alert("slide > 1");
}
});
};
})(jQuery);// JavaScript Document
,而不是給予警告幻燈片1它有錯誤
jQuery("#mainContent").setupQantas is not a function
如果我不要使用yepnope,只需在腳本標籤中使用它即可。當yepnope加載到js文件中似乎有延遲,並且似乎在doc.ready之前似乎沒有做到。
有沒有辦法解決這個問題?
謝謝
謝謝 - 完美:) – Dan 2013-03-01 05:08:15