Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Form Submit Reload
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'button',
attributeBindings: ['type'],
click(e) {
if(this.get('action')){
this.get('action')(this.get('params'));
}
}
});
import Ember from 'ember';
const { isEmpty } = Ember;
export default Ember.Controller.extend({
actions: {
submitAction({name='', message=''}) {
if(isEmpty(name) || isEmpt(message)) {
console.log('Fill Everything');
return false;
}
alert('Message Recieved');
}
}
});
<h1>Feedback</h1>
<form>
<div>
<label>Name:</label>
<input type="text" value={{name}} >
</div>
<div>
<label>Message:</label>
<textarea value={{message}}></textarea>
</div>
{{button-ui label="Submit" action=(action 'submitAction' (hash name=name message=message)) type="submit"}}
</form>
{
"version": "0.14.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "2.18.2",
"ember-template-compiler": "2.18.2",
"ember-testing": "2.18.2"
},
"addons": {
"ember-data": "2.18.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.