This works, but I really wonder if it is the proper way.. It seems like 
there are two objects being created and only one is being returned so 
the user really doesn't have access to the second one.

var Ajax.ExtendedInPlaceEditor = Class.create();
Object.extend(Ajax.ExtendedInPlaceEditor .prototype, 
Ajax.InPlaceEditor.prototype);
Object.extend(Ajax.ExtendedInPlaceEditor .prototype, {
    initialize: function(element, url, options) {
        Object.extend(new Ajax.InPlaceEditor(element, url, Object.extend({
            newOption: false,
            overriddenOption: true,
        }, options || {})), this);
        //more initialization if necessary
    },
    createEditField: function() {
    ...
    }
});

Maybe the better way would be to save the original initialize function 
under a different name before calling the second Object.extend and then 
calling it inside the new initialize? However, if this wouldn't play 
well with multiple inheritance if you always used the same name for the 
old initialize.. Anyone have a better way to extend a Prototype class 
that let's you call the original initialize function?

Unfortunately I've found every time I need to add features to IPE I 
always have to overwrite createEditField or some other function, but a 
lot of the code is copied. It really needs more "hooks" implemented so 
that you can add functionality simply by passing functions in the 
options or extending the prototype with new functions. For example, an 
onCreateEditField that is called after createEditField would let you do 
stuff like attach a popup calendar or WYSIWYG editor without overriding 
anything and without any code redundancy.

Colin

[EMAIL PROTECTED] wrote:
> You are right, Colin, I'll try to create something like that. I am
> just not much into javascript's object model and it would take some
> time to make myself comfortable with it :)
>
>
> >
>
>   


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" 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/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to