我对jQuery有一个非常-非常基本的知识,但我需要解决这个问题:我有一个基于Drupal的网页,我创建了一个在Colorbox中打开的地图(在彩色盒节点模块的帮助下)。因此,页面上有一个超链接:<a class="colorbox-node init-colorbox-node-processed-processed" href="/places_fullscreen">Open in fullscreen</a>。点击它,一个<div>与#colorbox css-选择器将可见在颜色盒覆盖.首先,我想在打开彩色盒子的时候看到这个事件,然后做一些事情。
我浏览过互联网寻找解决方案,并试图实现这些解决方案,但没有成功。
第一项建议:
(function($) {
$(".colorbox-node").colorbox( {
onComplete: function() {
console.log('ColorBox is currently open');
}
});
})第二项建议:
(function($) {
if ($("#colorbox").css("display")=="block") {
console.log('ColorBox is currently open');
}
})正确的解决办法是什么?
发布于 2015-04-20 15:57:45
我已经学会了我应该使用Drupal的行为。因此,下面的代码起了作用:
(function ($) {
Drupal.behaviors.whateverName= {
attach: function (context, settings) {
if ($('#colorbox').css('display') == 'block') {
console.log('ColorBox is currently open');
}
}
};
}) (jQuery);https://stackoverflow.com/questions/29694975
复制相似问题