Skip to content

Instantly share code, notes, and snippets.

@feanor07
Last active June 29, 2017 14:05
Show Gist options
  • Save feanor07/a7cffb165d9d27575b90f55d8276b0f8 to your computer and use it in GitHub Desktop.
Save feanor07/a7cffb165d9d27575b90f55d8276b0f8 to your computer and use it in GitHub Desktop.
so#44824022
import Ember from 'ember';
export default Ember.Controller.extend({
emailAddress:'',
isValid: Ember.computed.match('emailAddress', /^.+@.+\..+$/),
isDisabled: Ember.computed.not('isValid'),
actualEmailAddress: Ember.computed('emailAddress', function() {
console.log('actualEmailAddress function is called: ', this.get('emailAddress'));
}),
emailAddressChanged: Ember.observer('emailAddress', function() {
console.log('observer is called', this.get('emailAddress'));
}),
actions: {
saveInvitation() {
alert(`Saving of the following email address is in progress: ${this.get('emailAddress')}`);
this.set('responseMessage', `Thank you! We've just saved your email address: ${this.get('emailAddress')}`);
this.set('emailAddress', '');
},
onchange(val) {
alert(val);
}
}
});
<div class="jumbotron text-center">
<h1>Coming Soon</h1>
<br/><br/>
<p>Don't miss our launch date, request an invitation now.</p>
<div class="form-horizontal form-group form-group-lg row">
<div class="col-xs-10 col-xs-offset-1 col-sm-6 col-sm-offset-1 col-md-5 col-md-offset-2">
<input type="email" value=emailAddress class="form-control" placeholder="Please type your e-mail address." autofocus="autofocus"/><br>
{{input type="email" value=emailAddress class="form-control" placeholder="Please type your e-mail address." autofocus="autofocus"}}
</div>
<div class="col-xs-10 col-xs-offset-1 col-sm-offset-0 col-sm-4 col-md-3">
<button class="btn btn-primary btn-lg btn-block" disabled={{isDisabled}} {{action 'saveInvitation'}}>Request invitation</button>
</div>
</div>
<br/><br/>
</div>
<br>
is e-mail valid: {{isValid}}<br>
is disabled: {{isDisabled}}<br>
emailAddress Value: {{emailAddress}}
{
"version": "0.12.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-data": "2.12.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment