开始拖动时如何调用JavaScript? [英] How to invoke JavaScript when dragging starts?

查看:55
本文介绍了开始拖动时如何调用JavaScript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在像以下示例中那样处理拖放表: http://www.primefaces.org/showcase/ui/dndTable.jsf

i am working on drag and drop tables like in this example: http://www.primefaces.org/showcase/ui/dndTable.jsf

我想知道是否可以在开始拖动项目时调用JS代码来隐藏/显示组件.

and i was wondering if it's possible to invoke JS code to hide/show components when start dragging an item.

请告知,谢谢.

推荐答案

PrimeFaces使用jQuery可拖动交互功能,您需要检查这个.开球示例:

PrimeFaces using jQuery draggable interaction you need to check this out. Kickoff example:

$(function() {
  $( ".ui-dt-c" ).draggable({
      start: function() {
          alert(1);
      },
      drag: function() {
          alert(2);
      },
      stop: function() {
          alert(3);
      }
  });
});

如您所见,由于drag功能,这引发了重复发生的警报事件.您可以根据需要更改它.您也可以尝试将类更改为.ui-dt-c ui-draggable.就像在jQuery示例中一样,您可以通过其ID选择元素并覆盖该函数,但是p:dataTable id混乱了,因此通过class选择元素对我来说更有意义.

As you can see this is firing recurring alert events because of the drag func. you can change it as you wish. Also you can try to change class to .ui-dt-c ui-draggable. Like in the jQuery example, you can to select the element by it's ID and override the function however, p:dataTable id's are messed up so selecting element by it's class makes more sense to me.

这篇关于开始拖动时如何调用JavaScript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆