Depending on when you wanted to pass the additional argument you could
just attach it to the argument chain on bind

this.changeContent = this.changeContent.bindAsEventListener(this,
extraArgument);

Since we're already looking at that line of code, be careful,
reassigning the function to a bound version of itself could get tricky
if you decide to create a subclass of Dynamic.

--

http://positionabsolute.net



On Aug 4, 9:24 am, Liviu Timar <[email protected]> wrote:
> Hello,
> This is my first post here. Thus, I'll like to say hello to everybody
> in this community and I want to appologize if this question was asked
> before.
>
> I am a web developer for a site that has 1mil+ visitors/month: www
> [dot] ziare [dot] ro, and I want to use the Prototype Framework to
> make an element refresh itself (with an scriptaculous Effect)
> periodically.
>
> This is my class:
>
> var Dynamic = Class.create({
>         initialize: function(selector, container, script)
>         {
>                 this.selector  = selector;
>                 this.script    = script;
>                 this.container = container;
>
>                 this.changeContent = 
> this.changeContent.bindAsEventListener(this);
>
>                 this.getContent();
>         },
>         getContent: function()
>         {
>                 new Ajax.Request(this.script, {
>                         onSuccess: function(req)
>                         {
>                                 this.content = req.responseJSON;
>                                 //document.fire('content:retrieved', 
> req.responseJSON);
>                         }
>                 });
>                 $$(this.selector).invoke('observe', 'click', 
> this.changeContent.bind
> (this));
>         },
>         changeContent: function(event)
>         {
>                 event.preventDefault();
>                 console.log(this.content);
>                 console.log(this.container);
>                 /*new Effect.Fade($(this.container), { afterFinish: 
> function() {
>                                 new Effect.Appear($(this.container));
>                         }
>                 });
>                 $(this.container).update('cucu');*/
>         }});
>
> document.observe('dom:loaded', function() {
>         var dyn = new Dynamic(".tzNavLink a", "tzContent",
> "titlurileZilei.php");
>
> });
>
> 'tzContent' is the div whose content changes by clicking on of the
> links with the 'tzNavLink' css class (the 1 2 3 4 5 6 links onwww.ziare.ro).
>
> The problem is that this.content is undefined in changeContent (a
> function that listens for the click event), although this.container
> works well in the same function. Why is that? It has something to do
> with the Ajax.Request?
>
> Also, I want to ask how can I 'tzContent' to change periodically using
> such and object (I want everything to be encapsulated so I can use
> this object in other projects)?
>
> Thank you for your response.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" 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/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to