dynamic - jQuery reinitialize/refresh draggable/sortable elements dynamically -
I have some functions that I load in the prepared () event, they basically make a list dragable , And other areas are drop-worthy / sorted, for example. You can drag a clone into several areas (lists in the Divisions), and within these multiple areas, you can sort / reorder them (but only in each area). It works perfectly.
I have a button that dynamically creates a new area to drop objects, then sorted. This makes the new area fully, but you can not leave objects in it or you can even sort them.
I know that this is the fact that I use all the fields in the page load () event, and in reality these functions are not dynamically running again.
I have tried to use 'Refresh' on these elements within the click function of the button. E.g.
$ (".field"; li) Dragable ('Refresh'); $ ("Dragrow1, .dragrow2") Droppable ('Refresh'); $ ("Dragrow1, .dragrow2") Sorted ('refresh');
But that does not work if I can help it, then I want to avoid repeating my code in any way. Is this a way to work? I thought that if there is something similar to the 'live' function that you can use with 'ready', then this can be a solution, but not ...!
Thanks
Why not insert your initial code into your jQuery add-on in the form of? After that, the code can set that thing in the same way by adding your initial code as well as the dynamic element.
jquery (function () {jQuery.fn.myDroppableSetup = function myDroppableSetup ()} each (function () {// your setup code here}); it returns;}; jQuery.fn .myDraggableSetup = // ...});
Then you can use it only when you dynamically add things:
$ ('div.newlyAddedDroppable'). MyDroppableSetup ();
Comments
Post a Comment