1

There are widgets in dashboard page which be can sorted(draggable and droppable). We want the order of widgets to be preserved when user revisits our page, so we have API to dump all widgets to DB. But the problem is whether we should make an API call on every drag-drop of widget or before window close/unload? Having read around, got to know that doing API at window unload is not recommended. So is there any other approach to tackle this? I don't want to make API call on every drag-drop of widget.

Thanks in advance for help.

  • 1
    modern browsers have a sendBeacon method that may be of use, however the usual "doesn't work in internet explorer or safari" rules apply – Jaromanda X Jul 03 '17 at 03:52

2 Answers2

0

If you want to avoid doing a request every time a drag/drop operation is made, you could have a button(save changes) that might appear when a change is made. So the user would have to save the changes.

cccross
  • 76
  • 7
0

We figured out a way. Using navigator.sendBeacon() - (https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon)

Thanks to Jaromanda X.