jQuery-ui 可排序可拖动模块遇到多个问题?

发布于 2024-12-11 15:57:11 字数 1108 浏览 0 评论 0原文

(总而言之,我的问题可以在这里查看: http://jsfiddle.net/F5Wve/12/

所以我试图修复我正在与我的朋友一起工作的网站上运行的代码,FriendGrid ,我们使用 jQuery-UI 在三列界面中添加可排序模块,不幸的是,当我使用此 jQuery 为排列在列内的模块启动可拖动界面时,我的代码遇到了一些奇怪的错误与 connectWith 连接时会遇到这样的问题:模块在移动后会克隆自己,而它们只应该被移动:

$(".module").draggable({
    handle: $(this).children(".draghandle"),
    opacity: 0.5,
    helper: 'clone',
    revert: 'invalid',
    connectToSortable: '.column'
});

然后当我使用下一个代码来启动它而不是克隆模块时,它首先看起来会移动它,然后它完全删除它:

$(".module").draggable({
    handle: $(this).children(".draghandle"),
    opacity: 0.5,
    helper: 'original',
    revert: 'invalid',
    connectToSortable: '.column'
});

所以无论哪种方式,它都会忽略移动它,因为人们可能会注意到我更改的选项是助手,这也是所有这一切的主要因素,但如果助手是克隆,它应该只使用克隆本身被拖动,如果它设置为原始,它应该将模块完全移出它所在的位置并拖动模块本身,但我不明白为什么它会导致这些奇怪的问题,当前的设置该网站是克隆的,但您当然会必须创建一个帐户才能测试它,如果您希望可以立即删除该帐户,一旦您进入该网站,您需要调用 javascript 函数 ModularMode(),如果您不知道如何调用该函数通过输入“javascript: ModularMode();”即可轻松完成进入您的浏览器(不带引号)。希望我能得到一些有用的回复,谢谢。

(In summation, my problem can be viewed here: http://jsfiddle.net/F5Wve/12/)

So I am trying to fix the code I'm running on the website I'm working on with my friend called, FriendGrid
, we are using the jQuery-UI to add sortable modules in a three column interface, unfortunately I'm running into some strange bugs with my code, when I use this jQuery to initiate the draggable interface for modules being arranged inside of the columns which are connected with a connectWith it runs into the problem that the modules clone themselves after being moved, when they should only be moved:

$(".module").draggable({
    handle: $(this).children(".draghandle"),
    opacity: 0.5,
    helper: 'clone',
    revert: 'invalid',
    connectToSortable: '.column'
});

And then when I use this next code to initiate it instead of cloning the modules it at first looks like it's going to move it but then it removes it completely:

$(".module").draggable({
    handle: $(this).children(".draghandle"),
    opacity: 0.5,
    helper: 'original',
    revert: 'invalid',
    connectToSortable: '.column'
});

So either way it neglects to just move it, as one might notice the option I change is the helper, which is the main factor in all this as well, but if the helper is a clone it should just use a clone of itself to be dragged, and if it's set to original it should take the module entirely out of the spot it was in and drag the module itself, but I don't see why it would be causing these weird problems, the current setting on the site is clone, but you'll of course have to make an account to be able to test it, which if you wish you can delete immediately afterwords, and once you're on the site you need to call the javascript function ModularMode(), which if you don't know how can easily be done by entering "javascript: ModularMode();" into your browser (without quotes). I hope I can get some helpful responses, thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

嘿嘿嘿 2024-12-18 15:57:11

无论如何,您通过声明元素可拖动和可排序来重复工作。可排序具有所有相同的选项,因此您也可以在那里指定它们。您在使用脚本时遇到如此多麻烦的原因可能是表格单元格往往会导致库用于创建您想要的行为的 CSS 定位属性类型出现问题。我什至无法开始猜测克隆。但是,我已经成功地通过使用稍微不同的标记(无序列表)和元素定位来完成您尝试做的事情。您可以轻松地使用 div 包裹其他 div,但将所有列容器向左浮动,效果应该很好。 查看示例小提琴

与许多可排序元素一样,拖动的元素并不总是能轻松地捕捉到列表的底部,但它是可行的。您需要为列指定宽度和最小高度属性,以便当您从其中拖动所有元素时它们不会消失。

For what it's worth, you're duplicating effort by declaring your elements both draggable and sortable. Sortables have all the same options, so you may as well specify them there. The reason you're having so much trouble with the script is likely that table cells tend to create issues with the kind of CSS positioning attributes the library uses to create the behavior you want. I can't even begin to speculate about the cloning. However, I've managed to accomplish what you're attempting to do by using slightly different markup (unordered lists) and element positioning. You could just as easily use divs wrapping other divs, but float all of your column containers left and it should work out just fine. Check out the example fiddle.

Like with many sortables, the dragged element doesn't always easily snap to the bottom of a list, but it's workable. You'll want to specify a width and min-height attribute for your columns so they don't disappear when you drag all elements from them.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文