I would create a class and implement the toElement method on it.

Here Jan Kassens explains the toElement method:
http://blog.kassens.net/toelement-method


--
Fábio Miranda Costa
Solucione Sistemas
Engenheiro de interface


On Tue, Oct 13, 2009 at 7:54 AM, Dimitar Christoff <[email protected]>wrote:

>
> Here is the premise.
>
> i have created a simple class that allows me to setup a modal overlay on
> top of any element with an ajax spinner, with some options.
>
> which works just fine. currently the objective is to show the overlay
> before a page load so that the user is aware that something is taking
> place, i.e. their click has worked, the server is 'thinking'. in that
> regard, the next step is for a page transition and I don't need to
> remove the overlay or worry about it.
>
> but the reason why i chose to do this as a class is because i figured
> this could be reused when ajax is performed that updates certain
> elements. i added a .remove() method to the class which can be called
> from an onComplete etc.
>
> the downside to using the class is that i need to create an instance of
> it and the set an overlay ...
>
> so my question is, given the requirements of being able to create and
> remove it, would you choose to prototype element instead and how would
> you handle the removal, a second prototype?
>
> eg.
> Element.implement({
>    ajaxLoaderCreate: function(options) {
>        ...
>        return this.store("ajaxLoader", options.id); // or overlay
> element itself
>    },
>    ajaxLoaderRemove: function() {
>        var hasLoader = this.retrieve("ajaxLoader");
>        if (hasLoader)
>            $(hasLoader).dispose();
>        return this;
>    }
> });
>
> which is the better practice / what would you do and why?
>
> cheers
> --
> Dimitar Christoff <[email protected]> - http://fragged.org/
>
>

Reply via email to