N
N
nurzhannogerbek2018-03-03 08:02:50
JavaScript
nurzhannogerbek, 2018-03-03 08:02:50

Is it possible to somehow know in advance how many elements in the list to which the user wants to move the element?

Hello!

There are two lists. Users can move items between lists. I use for this Sortable | jQueryUI . The question is: The user has decided to move an element from list A to list B, but the user has not yet released the element (that is, the stop

event has not fired yet ). Is it possible to somehow know in advance how many elements in the list B to which the user wants to transfer the element? The over event gives information about how many elements are in the current list (list A) from which the element is transferred:


over: function(event, ui){
    console.log($('div[id='+ui.item.attr("id")+']').closest('.list-group').children().length);
},
beforeStop: function(event, ui){
    console.log($('div[id='+ui.item.attr("id")+']').closest('.list-group').children().length);
}


When using the beforeStop event , the number of elements of list B where the user drops the element is shown. The problem is that it shows the amount after the user releases the element, and I need to know in advance. Is there a way to solve this problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-03-03
@nurzhannogerbek

The list into which the item to be sorted will be placed is available as event.target in the over event handler.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question