Question about sortable refresh

Question about sortable refresh

Hello,


I have a system which allows to sort both tables and the rows inside them:
- you can click the "GROUP HANDLE" and move the table.
- you can also click the "ROW HANDLE" and move the row from one table to another.

You can also add new rows to the tables using the "Add Row" button and they will be automatically made sortable.

Up to there, no problem.

Then, if I add a table using the "Add Table" button, the table will be automatically made sortable. BUT, the rows won't. Reading the documentation, I stumbled on the 'refresh' method but calling it throw an error: "Uncaught Error: cannot call methods on sortable prior to initialization; attempted to call method 'refresh'".

Thanks to this message, I understood that sortable doesn't work like "on": the selector is processed one time and if something is added later that match the selector, it won't be made sortable. Only the new children of the existing sortable elements (the ones that matched the selector when the sortable was initiated) will be automatically made sortable.

I found the workaround: re-call sortable with all its parameters after I add the table.

So, my question is: is there a clever way to do this? Is there a way to make sortable behave like "on": if a new element that match the selector is added, it should be automaticaly made sortable with the specified parameters.

Thanks.