On 12 Feb, 13:49, Tobias Nurmiranta <[EMAIL PROTECTED]> wrote:
> Hi, when using prototype is would like to be able to get the class-
> name of an instance of class. As prototype Class if defined now, it's
> not possible.
>
> // Example
> var X = Class.create({});
> var x = new X();
> x.constructor.name // is "klass" not "X"Makes sense. > I've made a modification to Class to fix this, I've added an optional > parameter to create, so that if the first argument is a string, then > that is the class-name. Currently it also defines the class in the > global scope top. If you're using the top I think you're using then it's not such a great idea. > ..... > top[class_name] = klass; Well, it seems you're actually doing that. The problem here is that top refers to the top frame in the frame hierarchy. Not the top of the javascript scope in the current frame (if you can call it that). If you change to window[class_name] = klass; then I'll agree. Or do you really mean to refer to the top frame? /Marcus --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
