I know how to notify a value change in an object using Object.defineProperty, but I want to know how to notify a change in the value of a json object?
more about this
when create a new instance for strore and set the price value, notifyPriceChange will call ..
function store(){
var price
Object.defineProperty(this, "price",
{
get : function(){
return price;
},
set : function(newValue){
price = newValue;
notifyPriceChange();
},
enumerable : true,
configurable : true
});
}
I want to do the same here.
var obj = jQuery.parseJSON( '{"price":"120"}' );
obj.price = "John"
when I set the value to the price value, I want to notify. how to do it?
source
share