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

Pass parameters from markup to subviewCreator #12

Closed
nadavelyashiv opened this issue Jan 16, 2014 · 1 comment
Closed

Pass parameters from markup to subviewCreator #12

nadavelyashiv opened this issue Jan 16, 2014 · 1 comment

Comments

@nadavelyashiv
Copy link

Hi,
I started using this plugin, and I was missing the ability to pass params (in the shape of attributes, inner html, or whatever) to the subviewCreators function.
for example, I have a generic list view, and I want to set its items from within the markup, for example:

<div data-subview="mySubview" data-num-items="2">
  <li>item 1</li>
  <li>item 2</li>
</div>

I think that's possible if you send thisPlaceHolderDiv as a param in subviewCreator.apply() (line 80).

@dgbeck
Copy link
Member

dgbeck commented Jan 16, 2014

I don't think so.. the placeholder div should be just that, a place holder div. If you need to pass arguments to a subview creator function, store them somewhere you can get to via the view instance (i.e. the this object in the creator function).

subviewCreators : {
   mySubview : function() {
     var items = this.items;  // or hard code them, or pull them from an external source
     return new Subview( { items : items } );
     ...

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

No branches or pull requests

2 participants