0.2.0 • Published 9 years ago
ember-submit-button v0.2.0
ember-submit-button
submit-button is a small Ember component that has a handy list of features. Pass it the ember-data model being edited in a form and it will:
- Dynamically determine button text. (eg: if the model is an existing Post, the button text will be: Update Post)
- Automatically disable the button while the model
isSaving - Automatically change button text to Saving... while model
isSaving
Installation
ember install ember-submit-buttonUsage
The simplest use case
<form {{action 'save' on='submit'}}>
// ...
{{submit-button model=group}}
// ...
</form>Custom Text
{{#submit-button model=post}}
{{if post.isDraft 'Publish' 'Update'}} Post
{{/submit-button}}Calling a custom action on click
{{submit-button model=post action="publish"}}Custom 'isSaving' text
{{submit-button model=post savingText="Submitting"}}Not passing in a model and providing a Boolean value for if its disabled
{{submit-button disabled=someVariable}}Component API
model: Ember Data Model
The model to observe. If save() has been triggered on the model, component will automatically disable to the button so it cannot be clicked again.
disable: {Boolean}
Default: null
Passing in a disable value will cause the component to ignore the model attribute all together. The component will watch this attribute and update accordingly.
savingText: {String}
Default: Saving
action: {String}
A custom action to fire on click.
Contributing
Installation
git clonethis repositorynpm installbower install
Running
ember server- Visit your app at http://localhost:4200.
Running Tests
npm test(Runsember try:testallto test your addon against multiple Ember versions)ember testember test --server
Building
ember build
For more information on using ember-cli, visit http://www.ember-cli.com/.