如何捕获放置的项目内文本框的值

发布于 2024-09-02 00:37:19 字数 289 浏览 2 评论 0原文

我正在使用 JQuery 插件 Draggable 和 droppable 以及 这是我的可拖动项目结构。

文本框值是放入购物车的商品数量。 用户在将其放入购物车部分之前将对此进行更改。 我需要在其下降后捕获该值。

 <div class="something">
    <ul>

     <li>


            TEXTBOX 1

     </li>
    </ul>

    <div>

I am using the JQuery plugins Draggable and droppable and
this is my draggable item structure .

The Textbox value is the qty of the item being dropped onto a shopping cart.
This will be changed by the user before he drops it onto the cart section.
I need to capture this value after its dropped.

 <div class="something">
    <ul>

     <li>


            TEXTBOX 1

     </li>
    </ul>

    <div>

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

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

发布评论

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

评论(2

月寒剑心 2024-09-09 00:37:19

如果您将表单拖动到放置功能上的另一个 div 中,您需要引用放置的项目。您需要设置与此类似的放置区域才能获得该项目的值。

$("#dropArea").droppable({drop: function(event, ui) {
        var num = ui.draggable.val();
    }
})

ui.draggable 将是被拖动的元素。

我没有使用 .val() 测试代码,但我知道这就是您删除元素的方式,因此请尝试一下。

If you're dragging the form into another div on the drop function you'd want to reference the dropped item. You'd need to setup your drop area similar to this in order to get that items value.

$("#dropArea").droppable({drop: function(event, ui) {
        var num = ui.draggable.val();
    }
})

The ui.draggable would be the dragged element.

I didn't test the code with the .val() but I know this is how you would get the element being dropped so play around with it.

一世旳自豪 2024-09-09 00:37:19

我的问题应该更详细一些。实际上,问题在于,在该 UL 中,我有一个 ListViewDataItem,它将被渲染为 LI ofc。在每个 LI 中,我都有多个控件,其中一个是 TExtBox1。

我发现在“drop:function(...){}”中,我将使用 $(ui).find(".className") 来查找具有特定类的 textBox1,然后使用其 value 属性得到我想要的数量:)

感谢您的帮助:)

I should have been a little more detailed in my question. Actually the trouble was that within that UL I had a ListViewDataItem which would get rendered as a LI ofc. And in each LI I had multiple controls of which one was this TExtBox1.

I figured out that in the "drop:function(...){}" I would use the $(ui).find(".className") to find the textBox1 which had a particular class and then used its value property to get the qty I wanted :)

Thanks for the help :)

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