Assign object property to a jQuery object
When i do this:
var obj = {
element: $('#myDiv')
};
watch(object, function(prop, action, newvalue, oldvalue) {
console.log(prop, action, newvalue,oldvalue,this);
});
Throws a error: TypeError: obj.watchers[prop].push is not a function
watch.js (line 258)
obj.watchers[prop].push(watcher); //add the new watcher in the watchers array
Hi, I understand your concern but the best I can do is check if it is a jQuery Object and throw an specific exception telling that you should observe only your own objects.
jQuery objects are huge and with a lot of cyclic references. The idea of Watch.JS is to use in your own objects. I think you should use the jquery event features.
A good idea is to create another project: a jQuery plugin to adapt jQuery objects to Watch.JS
See please http://jsfiddle.net/KwQbc/16/ the same situation when the we watching object Array and push it to the object and the object set changes
I think now you are asking too much HAHAHA I dont know if we could watch an array directly, I will think about it, analyse the code and let you know
but thanks for reporting this