oh ok thanks a lot.

>   *$this* is like a binding kind of global variable inside of my
>   object ?
>

Not global. Each function has it' own scope. The $this variable was created
on the parent functions'(get_configuration2) scope.



> > It's on purpose because I'm more familiar with the ajax on jquery but
> > I wouldn't mind using mootool request.
>


If all you are looking for is using Class, there is no problem with running
it with JQ (as a standalone). But if what you are doing is loading both libs
than don't. Working with 2 libs together is a bad idea, if only because of
the unnecessary performance hit. If you're trying to learn the mootools
syntax, the mootorial <http://mootorial.com/wiki/> is a great place to
start, although it's a little outdated in some parts (minor issues so you
shouldn't worry about it).


The console told me I had an error with this *$this* = this;
> but i removed the stars and just put $this = this; and now it work
> perfectly.
>


This is how Google groups handles styles.




>  > תודה
> >
> > On 28 oct, 10:01, אריה גלזר <[email protected]> wrote:
> >
> >
> >
> >
> >
> >
> >
> > > You are mixing jQuery code with moo. is this on purpose or are you
> simply
> > > unfamiliar with the mootools Request syntax?
> >
> > > anyway, since you are mixing libs and I'm not sure the JQ way, the
> simplest
> > > way is to use the parent scope:
> >
> > > get_configuration2 : function(Url){
> > >        alert("conf loading");
> >
> > >        *$this* = this; //scope magic
> >
> > >         $.getJSON(Url, function(data) {
> > >                *$this*.fireEvent("Ready"); // in da works
> > >        });
> >
> > >    }
> >
> > > On Thu, Oct 28, 2010 at 9:48 AM, Léo SEI <[email protected]> wrote:
> > > > Hey all, I'm trying to create a module that needs to do some request
> > > > in Ajax and fire event when those request are done.
> >
> > > > I'm having trouble to use the fireEvent function of my class inside
> of
> > > > ajax callbacks function.
> >
> > > > this is my code.
> >
> > > > the get_confguration works because the request is not asynchronous
> but
> > > > i'd like to it asynchronously (like in get_configuration2). But in
> > > > that case, this doesn't point to the right object so the fireEvent
> > > > function doesn't exist for this "this".
> > > > how could i get back my point to the Network object from the callback
> > > > function of my getJSON query ?
> >
> > > > var Network = new Class({
> > > >    Implements: Events,
> >
> > > >    initialize : function(PluginId){
> > > >        this.Plugin = document.getElementById(PluginId);
> > > >        this.Conf = null;
> > > >        this.Name = "Network Plugin";
> >
> > > >    },
> >
> > > >    get_configuration : function(Url){
> > > >        var html = $.ajax({ url: Url , async: false }).responseText;
> > > >        this.Conf = JSON.decode(html);
> > > >        this.fireEvent("Ready");
> > > >    },
> >
> > > >    get_configuration2 : function(Url){
> > > >        alert("conf loading");
> > > >         $.getJSON(Url, function(data) {
> > > >                this.fireEvent("Ready");
> > > >        });
> >
> > > >    }
> >
> > > > });
> >
> > > >    var Ntw = new Network("pluginNetw");
> > > >    Ntw.addEvent("Ready",function(){alert("ready ");});
> > > >    Ntw.get_configuration("Javascript/conf.txt"); //this trigger Ready
> > > >    Ntw.get_configuration2("Javascript/conf.txt"); //this doesn't
> >
> > > > Thanks for your help
> > > > Greetings
> >
> > > > Léo
> >
> > > --
> > > Arieh Glazer
> > > אריה גלזר
> > > 052-5348-561
> > > 5561
>
>


-- 
Arieh Glazer
אריה גלזר
052-5348-561
5561

Reply via email to