سؤال

I would like to detect if any of an object's property has changed. Something like:

var object = { property: 'value' };
$(object).onPropertyChange(function(property, newValue){
    console.log('object changed: ', property, newValue);
})

Is this somehow possible?

هل كانت مفيدة؟

المحلول

You could use some JS plugins like Watch JS. this keep tracks of whole object changes or even if a single attribute has changed.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top