【问题标题】:Make Images in Mootools Wall plugin clickable使 Mootools Wall 插件中的图像可点击
【发布时间】:2012-04-27 10:36:33
【问题描述】:

我正在使用 Mootools “The Wall”插件创建图像墙。它的创建在 initWall() 上没有任何问题,但是如果我将图像包装在“a”标签中,则在拖动完成后,单击链接并将我传送到 href,即使我没有单击它.这是我的代码

window.addEvent("domready", function() {
new Wall("wall", {
width: 260,
height: 180,
rangex: [-10,10],
rangey: [-10,10],
inertia: true,
callOnUpdate: function(items) {
  items.each(function(item) {
    var a=new Element("a",{
        href:"post.php",
        styles: {
            opacity: 0
            }
        });
    var img=new Element("img",{
        src:"img/260x180.gif"
        });
    img.inject(a);
    a.inject(item.node).fade(1);
  });
}
}).initWall();  
});

生成的 HTML 是这样的

<div class="tile" col="-1" row="-1" rel="-1x-1" style="position: absolute; left: -260px; top: -180px; width: 260px; height: 180px; ">
    <a href="post.php" style="visibility: visible; zoom: 1; opacity: 1; ">
        <img src="img/260x180.gif">
    </a>
</div>

如何使项目本身成为最外层的类,使项目看起来像

<a href="post.php" class="tile" col="-1" row="-1" rel="-1x-1" style="position: absolute; left: -260px; top: -180px; width: 260px; height: 180px; ">
    <img src="img/260x180.gif">
</a>

更新:已答复 好的。我自己想通了。需要添加“点击”事件处理程序并使用 getMovement 函数。

a.addEvent("click",function(e){
if( wall.getMovement() ){
    e.stop();
    }
});

【问题讨论】:

    标签: javascript jquery jquery-plugins mootools


    【解决方案1】:

    好的。我自己想通了。需要添加“点击”事件处理程序并使用 getMovement 函数。

    a.addEvent("click",function(e){
    if( wall.getMovement() ){
        e.stop();
        }
    });
    

    【讨论】:

      猜你喜欢
      • 2016-12-30
      • 2012-01-01
      • 1970-01-01
      • 2018-08-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多