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

Dynamic attribute setters #306

Merged
merged 1 commit into from
Sep 3, 2014
Merged

Dynamic attribute setters #306

merged 1 commit into from
Sep 3, 2014

Conversation

danwrong
Copy link
Contributor

Default or given attributes can be a function that gets evaluated at initialize time in the context of the component for dynamic attr setting.

this.attributes({ 
   href: function() {
    return this.$node.attr('href');
  }
});

but you can also do it at attach time:

Tweet.attachTo('.tweet', {
  tweetId: function() { return this.$node.data('tweet-id') }
});

SICK!

…initialize time in the context of the component for dynamic attr setting
@tgvashworth
Copy link
Contributor

Like it. Needs documentation?

@angus-c
Copy link
Contributor

angus-c commented Sep 2, 2014

I like. Is there a risk that a flight client's legacy code might include function attrs that they didn't intend to be evaluated?

@danwrong
Copy link
Contributor Author

danwrong commented Sep 2, 2014

Was intending to update with docs if people liked the idea.

Re legacy: This only works for this.attributes so shouldnt be too much of an issue.

@angus-c
Copy link
Contributor

angus-c commented Sep 2, 2014

ah good point - ship it

angus-c added a commit that referenced this pull request Sep 3, 2014
@angus-c angus-c merged commit 979563d into master Sep 3, 2014
@tgvashworth
Copy link
Contributor

Let's make sure we get this documented.

@angus-c
Copy link
Contributor

angus-c commented Sep 7, 2014

ah - good point...sorry merged prematurely

@necolas necolas deleted the dynamic_attributes branch October 29, 2014 17:50
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

Successfully merging this pull request may close these issues.

3 participants