retrieving name of a class?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • leftist
    New Member
    • Jan 2007
    • 1

    retrieving name of a class?

    Let's say that I've created an object:

    Code:
    var Model = Class.create();
    Model.prototype = { ... }
    Search = new Model();
    I can't for the life of me get my Model object to tell me that it's name is Search.

    Anyone have a clever trick?

    Pete
  • b1randon
    Recognized Expert New Member
    • Dec 2006
    • 171

    #2
    Originally posted by leftist
    Let's say that I've created an object:

    Code:
    var Model = Class.create();
    Model.prototype = { ... }
    Search = new Model();
    I can't for the life of me get my Model object to tell me that it's name is Search.

    Anyone have a clever trick?

    Pete
    It is sort of hard to imagine why you want to do that. But one thing you could do is pass "search" as a parameter to your constructor and in the constructor you can set a member variable called name to "search". Then your model class would know the name of the variable it was stored under. It is still a weird problem. Please post more about why you're doing that.

    Comment

    Working...