2010-05-28 46 views
1

首先,道歉。我是一个js新手。Shadowbox + jQuery不工作 - 没有错误

我试图用特定页面的负载触发一个shadowbox - 如果您愿意的话,会弹出一个“弹出窗口”。根据萤火虫,没有任何反应,没有错误可以报告。

我应该注意到这是wordpress,所以我使用默认的jQuery调用,并将shadowbox插入WP插件中。 Shadowbox可以在网站的其他区域正常工作,就像jQuery的功能一样。

noConflict()被使用,因为WP也默认加载原型,这与jQuery美元符号冲突。

var $j = jQuery.noConflict(); 

     $j(function(){ 
      //Set cookie 
       $j.cookie('padpop_viewed',true); 

        // open a welcome message as soon as the window loads 
      $j(function() { 
       Shadowbox.open({ 
       content: '<div width="600" height="460" style="margin:auto;"><a href="<?php bloginfo('url');?>"/products/"><img src="<?php bloginfo('template_url');?>/images/ipad-pop.jpg" width="600" height="460" alt="Redacted"/></a></div>', 
        player: "html", 
       height: "470", 
       width: "610" 
       }); 
      }); 
     }); 

这里的任何帮助将不胜感激,因为我花了几个小时咨询了这方面的文档。

感谢, S.

回答

2

你不应该巢$(function() { ... })电话。

删除内部$j(function() {

编辑:和呼叫

Shadowbox.init({ 
    // let's skip the automatic setup because we don't have any 
    // properly configured link elements on the page 
    skipSetup: true 
}); 
+0

完成!但仍然没有骰子。 – Shelton 2010-05-28 21:22:00

+0

完成。但仍然无法正常工作......现在,Shadowbox无法正常工作。 我怀疑WP插件默认情况下会启动init调用。我只是确保将我的代码放在wp_head函数下面。 – Shelton 2010-05-28 21:42:46