如何捕获放置的项目内文本框的值
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您将表单拖动到放置功能上的另一个 div 中,您需要引用放置的项目。您需要设置与此类似的放置区域才能获得该项目的值。
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.
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.我的问题应该更详细一些。实际上,问题在于,在该 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 :)