2012-10-27 72 views
1

只需调用.trigger(“mousedown”);不起作用。如何在jQuery UI中以编程方式触发可拖动?

scrollPane_Y.draggable({ 
    axis: "y", 
    stop: function (event, ui) { 
     /* 
     i get triggered when the containment is hit 
     so if a user hits the containment and then 
     goes in the other direction nothing happens. 
     */ 
     scrollPane_Y.trigger("mousedown"); // doesnt work 
     scrollPane_Y.mousedown(function (e) { // from third link. doesnt work 
      scrollPane_Y.trigger(e); 
     }); 
    }, 
    containment: [0, min_scrollPane_Y, 0, max_scrollPane_Y] 
}); 
+0

你能更清楚吗?拖动元素命中容器时是否要停止用户操作? – sdespont

+0

只是写我自己的。 – user1764195

回答

0

你可以直接打电话与正确的参数的私有方法。

scrollPane_Y.draggable({ 
    axis: "y", 
    stop: function (event, ui) { 
     /* 
     i get triggered when the containment is hit 
     so if a user hits the containment and then 
     goes in the other direction nothing happens. 
     */ 

     // retrieve the instance and call its private method 
     scrollPane_Y.data("ui-draggable")._mouseDown(event); 
    }, 
    containment: [0, min_scrollPane_Y, 0, max_scrollPane_Y] 
}); 
相关问题