【问题标题】:jQuery.tubular not accepting inputjQuery.tubular 不接受输入
【发布时间】:2015-03-08 19:59:38
【问题描述】:

我目前正在使用 jQuery.tubular (Here) 在后台显示 YT 视频,其中 ID 是使用 YouTube 数据 API 获取的。 Tubular 加载,但没有加载我要求的视频,无论出于何种原因。这是相关的JS:

var output;
$(document).ready(function() {
  getURLPs(); //parses url params into an array, this works
  $('#content').hide().delay(7000).fadeIn('slow');
  console.log('ID: '+urlParams["id"]);
  console.log('Title: '+urlParams["title"]);
  tubularoptions = '{videoId: \''+urlParams["id"]+'\'}';
  console.log('Passing \"'+tubularoptions+'\" to jQuery.tubular.');
  $('#wrapper').tubular(tubularoptions);
  output = '<span class=\"animlink\"><a href=\"http://www.youtube.com/watch?v='+urlParams["id"]+'\">'+urlParams["title"]+'</a></span>';
  $('#nowplaying-text').append(output);
  $('#preloader').delay(1000).fadeOut('slow',function(){$(this).remove();});
});

控制台显示如下:

ID: G15btlaZR_k
Title: Ryos ft. Allisa Rose - Eclipse
Passing "{videoId: 'G15btlaZR_k'}" to jQuery.tubular.

但随后 tube 加载默认视频。一切看起来都应该有效,但事实并非如此。有什么线索吗?

【问题讨论】:

    标签: javascript jquery tubular


    【解决方案1】:

    你传递的是一个字符串而不是一个对象

    这行得通

    var output;
    var urlParams = {id:'G15btlaZR_k', title:'Ryos ft. Allisa Rose - Eclipse'};
    $(document).ready(function () {
        $('#content').hide().delay(7000).fadeIn('slow');
        $('#content').hide().delay(7000).fadeIn('slow');
        console.log('ID: ' + urlParams["id"]);
        console.log('Title: ' + urlParams["title"]);
        tubularoptions = '{videoId: \'' + urlParams["id"] + '\'}';
        console.log('Passing \"' + tubularoptions + '\" to jQuery.tubular.');
        //*************************************************
        $('#wrapper').tubular({videoId: urlParams["id"] });
        //*************************************************
        output = '<span class=\"animlink\"><a href=\"http://www.youtube.com/watch?v=' + urlParams["id"] + '\">' + urlParams["title"] + '</a></span>';
        $('#nowplaying-text').append(output);
        $('#preloader').delay(1000).fadeOut('slow', function () { $(this).remove(); });
    });
    

    这也是

    var output;
    var urlParams = {id:'G15btlaZR_k', title:'Ryos ft. Allisa Rose - Eclipse'};
    $(document).ready(function () {
        $('#content').hide().delay(7000).fadeIn('slow');
        $('#content').hide().delay(7000).fadeIn('slow');
        console.log('ID: ' + urlParams["id"]);
        console.log('Title: ' + urlParams["title"]);
        //*************************************************
        var tubularoptions = { videoId: urlParams["id"] };
        //*************************************************
        console.log('Passing \"' + tubularoptions + '\" to jQuery.tubular.');
        $('#wrapper').tubular(tubularoptions);
        output = '<span class=\"animlink\"><a href=\"http://www.youtube.com/watch?v=' + urlParams["id"] + '\">' + urlParams["title"] + '</a></span>';
        $('#nowplaying-text').append(output);
        $('#preloader').delay(1000).fadeOut('slow', function () { $(this).remove(); });
    });
    

    【讨论】:

      猜你喜欢
      • 2014-09-08
      • 2013-08-27
      • 2014-01-24
      • 2021-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-25
      相关资源
      最近更新 更多