Skip to content
This repository has been archived by the owner on Mar 22, 2022. It is now read-only.

Assign object property to a jQuery object #46

Open
zzarcon opened this issue May 22, 2013 · 4 comments
Open

Assign object property to a jQuery object #46

zzarcon opened this issue May 22, 2013 · 4 comments

Comments

@zzarcon
Copy link

zzarcon commented May 22, 2013

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

@melanke
Copy link
Owner

melanke commented Jun 3, 2013

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.

@melanke
Copy link
Owner

melanke commented Jun 3, 2013

A good idea is to create another project: a jQuery plugin to adapt jQuery objects to Watch.JS

@melanke melanke closed this as completed Sep 11, 2013
@ale4ko
Copy link

ale4ko commented Sep 11, 2013

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

@melanke
Copy link
Owner

melanke commented Sep 11, 2013

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

@melanke melanke reopened this Sep 11, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants