开发者

How to capture the value of a textbox inside the dropped item

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>


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.


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 :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜