问题
I am using GalleryView and when load the script in the head like this
<script type="text/javascript" src="/js/galleryview/jquery.easing.1.3.js"></script>
<script type="text/javascript" src="/js/galleryview/jquery.galleryview-2.1.js"></script>
<script type="text/javascript" src="/js/galleryview/jquery.timers-1.2.js"></script>
everything works fine but when I use jquery to load the like this
$(document).ready(function(){
$('#gallery').hide();
$('<link />').appendTo('head').attr({
type: 'text/css',
rel: 'stylesheet',
href: '/js/galleryview/galleryview.css'
});
$.getScript('/js/galleryview/jquery.easing.1.3.js', function() {
$.getScript('/js/galleryview/jquery.galleryview-2.1.js', function() {
$.getScript('/js/galleryview/jquery.timers-1.2.js', function() {
$('#gallery').show();
$('#gallery').galleryView({
transition_speed: 1200,
background_color: '#006',
border: 'none',
easing: 'easeInOutBack',
pause_on_hover: true
});
});
});
});
});
I get 404 on the nav buttons
http://mydoamian/undefineddark/prev.gif
http://mydoamian/undefineddark/next.gif
any help would be appreciated
回答1:
I was able to get around this by modifying the code at line 853 by defining theme path as an empty string first
$('script').each(function(i){
var s = $(this);
theme_path = '';
if(s.attr('src') && s.attr('src').match(/jquery\.galleryview/)){
loader_path = s.attr('src').split('jquery.galleryview')[0];
theme_path = s.attr('src').split('jquery.galleryview')[0]+'themes/';
}
then in my call to galleryView I define nav_theme appropriately
$('#gallery').hide();
$('<link />').appendTo('head').attr({
rel: 'stylesheet',
type: 'text/css',
href: prefix +'js/galleryview/galleryview.css'
});
$.getScript(prefix +'js/galleryview/jquery.easing.1.3.js', function() {
$.getScript(prefix +'js/galleryview/jquery.galleryview-2.1.js', function() {
$.getScript(prefix +'js/galleryview/jquery.timers-1.2.js', function() {
$('#gallery').show();
$('#gallery').galleryView({
transition_speed: 1200,
background_color: '#006',
border: 'none',
easing: 'easeInOutBack',
nav_theme:prefix +"js/galleryview/themes/dark"
});
});
});
});
来源:https://stackoverflow.com/questions/3688011/loading-galleryview-script-using-jquery-causes-problem