No, that's what I meant - jQuery works with regular plain JavaScript
objects - NOT just DOM elements.
Go ahead and give your example a try, it'll work.
--John
On Fri, Nov 14, 2008 at 3:36 PM, Rainaer <[EMAIL PROTECTED]> wrote:
>
> when you say $(someObject) You have to have a reference to that object
> via id, class, or tag, meaning that jquery only has visibility into
> the DOM.
>
> how would I do something like
>
> var someObject = {};
> someObject.foo = "bar";
> someObject.baz = function () { alert("hello world") };
>
> $(someObject).bind("someEvent", someFunc);
> $(someObject).trigger("someEvent");
>
> if someObject is not a member of the DOM with a tag, class, or id?
>
> Forgive me, I'm still a newb to all of this.
>
> Robert Zumwalt.
>
> On Nov 14, 12:37 pm, "John Resig" <[EMAIL PROTECTED]> wrote:
>> What is a "Data Object" or a "Data Element" - I'm unfamiliar with those
>> terms.
>>
>> You can register events on regular JavaScript objects, with jQuery:
>> $(someObject).bind("someEvent", someFn);
>>
>> and trigger them:
>> $(someObject).trigger("someEvent");
>>
>> You can also bind data to objects:
>> $(someObject).data("someData", "someValue");
>>
>> and track when they get changed using events:
>> $(someObject).bind("setData", function(e, key, value){
>> ... do some setting ...}).bind("getData", function(e, key){
>>
>> return ... some value ... ;
>>
>> });
>>
>> --John
>>
>>
>>
>> On Fri, Nov 14, 2008 at 1:23 PM, Rainaer <[EMAIL PROTECTED]> wrote:
>>
>> > Are there currently, or are there plans to impliment, event handling
>> > on Data Objects like in Prototype such that you can register an
>> > observe event on a data element to fire a trigger when the data is
>> > changed?
>>
>> > Or is this something that I'll have to look to Prototype to impliment?
>>
>> > Thank you
>>
>> > Robert Zumwalt- Hide quoted text -
>>
>> - Show quoted text -
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---