SBB SBB - 1 year ago 168
jQuery Question

jQuery compare two serialized objects

I am using a plugin that has an API for events

. When I start dragging the element in the grid, It creates a serialized array of all the data in its current state.

When the item is dropped, it also creates a serialized array of data.

I want to compare these two sets of data to see if it has changed at all. I don't want to trigger a database call to update the grid placement if the user started dragging something and then put it back in its previous spot.

I have tried comparing them as is using
and I have also used
on them first before comparing but have read that it could provide mixed results.

Is there an easy to way to compare two objects like this?

enter image description here

Answer Source

== checks if object's references are equal (doesn't compares content).

For deep object comparison, you can use lodash's isEqual().

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download