Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document how to use component names functionality #3

Open
johngalambos opened this issue Jun 20, 2013 · 4 comments
Open

Document how to use component names functionality #3

johngalambos opened this issue Jun 20, 2013 · 4 comments

Comments

@johngalambos
Copy link

Hi,

I'm having trouble figuring how to use the new component names functionality--in particular I can't figure out how to set the name property of the constructor. Would you be able to provide an example? My best guess is something like this but it doesn't seem to work:

TestView = Backbone.View.extend({
  initialize: function () {
  }, {
    name: "TestView"
  }
})

Thanks for the great extension!

@Maluen
Copy link
Owner

Maluen commented Jun 21, 2013

Hi, you can specify the constructor name by providing a named function for the "constructor" property:

TestView = Backbone.View.extend({
  constructor: function TestView() {
      Backbone.View.apply(this, arguments);
  }
})

The constructor.name is used for all the components categories, in addition to that, the "title" or "name" attribute is used for Model as an additional name, the url property is used for Collection as an alternative to the constructor.name.

Maybe I should add a wiki page for explaining this, but the purpose is to use an heuristic that works in most cases.

@johngalambos
Copy link
Author

Ok got it! Thanks for your help.

@timmfin
Copy link

timmfin commented Sep 25, 2013

+1 to documenting this. I wasn't getting many names in Backbone-Debugger with Coffeescript (since coffeescript doesn't support function w/names).

@Maluen Maluen reopened this Sep 25, 2013
@Maluen
Copy link
Owner

Maluen commented Sep 25, 2013

Yeah, maybe it's time to add some documentation about that and other features. In the meantime, take a look at the pull request that introduced the functionality, if you have some ideas for improving it fell free to post them there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants