简体   繁体   English

锚在mootools中不起作用

[英]anchors are not working in mootools Sortables

I have created a table using mootools sortables to implement drag and drop functionality. 我已经使用mootools可排序对象创建了一个表格,以实现拖放功能。 Inside my table some of the columns has hyperlink and textboxes.When I click on hyperlink/input box it always calls Sortable's callback like onComplete. 在我的表格中,有些列包含超链接和文本框。当我单击超链接/输入框时,它总是像onComplete一样调用Sortable的回调。

How do I make hyperlink/input Elements working inside Sortable.I have tried to use handle property of Sortable but problem with this property is that it takes only one element.If I have to use multiple columns of of row as handle then what I need to do ?Do I have any hope ? 我如何使超链接/输入元素在Sortable中工作。我试图使用Sortable的handle属性,但是此属性的问题是仅需要一个元素。如果我必须使用行的多列作为句柄,那么我需要要做?我有什么希望吗?

Thanks in advance. 提前致谢。

It's not true you can only use one element as a handle. 只能使用一个元素作为句柄是不对的。 You can specify a handle by using CSS selectors in the handle option. 您可以通过在handle选项中使用CSS选择器来指定一个句柄。 This then refers relative to the 'sortable' (the element to be sorted). 然后,这是相对于“可排序”(要排序的元素)而言的。

So suppose within your sortable item (like an <li> html element) your handle is a <span> with the class my-handle , you could do: 因此,假设在您的可排序项(如<li> html元素)中,您的句柄是带有my-handle类的<span> ,您可以这样做:

var mySortables = new Sortables('#list-1', {
    handle: '.my-handle'
});

I think it's neater to solve it like that, instead of stopping event propagation of events you didn't want in the first place. 我认为这样解决是比较整洁的,而不是首先停止不需要的事件的事件传播。

I was able to solve the problem by adding following code in domready to prevent event bubbling. 通过在domready中添加以下代码来防止事件冒泡,我能够解决此问题。

    document.getElements("a").addEvents({
        click: function(e) {
            if (!e) var e = window.event;
                e.cancelBubble = true;
            if (e.stopPropagation) 
                e.stopPropagation();
        }
    });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM