How to invoke JavaScript when dragging starts?

坚强是说给别人听的谎言 提交于 2020-01-16 20:04:54

问题


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

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

please advise, thanks.


回答1:


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);
      }
  });
});

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.



来源:https://stackoverflow.com/questions/16262698/how-to-invoke-javascript-when-dragging-starts

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!