R
R
Roman Khodakovsky2018-12-04 10:18:53
JavaScript
Roman Khodakovsky, 2018-12-04 10:18:53

How to make friends Vue.js and jQuery UI sortable?

Good afternoon!
I connect the jQuery UI sortable plugin to the mounted component, everything works, everything is dragged, but I don’t know how to reactively update the order in the data of the Vue.js instance
I understand that I need to hang the sortable:update handler, but I don’t understand how to force Vue.js to update the data in according to the sorted DOM.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-12-04
@h_roman

Or maybe you should stop doing nonsense (in the sense of trying to use jquery in conjunction with vue), and try to look towards something more suitable ?
Well, there are no problems: add some attribute (of type data-id) to DOM elements, which will set the relationship between the DOM element and the data element; add an update handler to your sortable, in which you get DOM elements, pull out the attribute values, rebuild the source data in accordance with their order. For example .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question