May you need to 'bind'?
Behaviours.prototype.list = function() {
this.each(function(behaviour) {...});
}.bind(this);
Just a quick thought..
On Jan 21, 2008 8:17 PM, iporter <[EMAIL PROTECTED]> wrote:
>
> In the below code, one behaviours object is shared between all popup
> objects when what I'd like is for each popup object, and in fact each
> complexDOM object, to have it's own behaviours object.
>
> If I move this.behaviours = new Behaviours(); to the Popup() function,
> then each popup object then get's it's own Behaviours object as I'd
> like. However, I need to declare it in complexDOM, since all
> complexDOM's will have behaviours. Can anyone tell me why this is not
> working as I expect, and what the solution is?
>
> function Behaviours () {
> this.array = new Array();
> }
>
> Behaviours.prototype.push(el, event, method) = function() {
> this.array.push({el, event, method});
> }
>
> function complexDOM () {
> this.behaviours = new Behaviours();
>
> }
>
> function Popup () {
> this.options...
> }
>
> Popup.prototype = new complexDOM();
>
> I also found that I was unable to use the below - when trying to loop
> through this in the list function, 'this' didn't have an array data
> structure:
>
> function Behaviours () {}
> Behaviours.prototype = new Array();
> Behaviours.prototype.list = function() {
> this.each(function(behaviour) {...});
> }
>
>
> Thanks!
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" 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/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---