On Aug 4, 2:24 pm, Liviu Timar <[email protected]> wrote:
> 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;

This is ths problem. Inside the function definition, there is a new
scope, and 'this' will not have been assigned (because callbacks don't
get called as methods).

Either you need to #bind your onSuccess function, or I would just use
another variable:

getContent: function()
{
   var that = this;
   onSuccess: function(req)
   {
       that.content = req.responseJSON;
...

--~--~---------~--~----~------------~-------~--~----~
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