It's on purpose because I'm more familiar with the ajax on jquery but
I wouldn't mind using mootool request.
oh ok thanks a lot.
*$this* is like a binding kind of global variable inside of my
object ?

תודה

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

Reply via email to