-
-
Save samthidny/0de7a10c20cdef6c19d57aacbd560b50 to your computer and use it in GitHub Desktop.
Nucleus template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ember from 'ember'; | |
| export default Ember.Controller.extend({ | |
| appName: 'Ember Twiddle' | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ember from 'ember'; | |
| export default Ember.Component.extend({ | |
| isValid: true, | |
| model: { | |
| firstname: 'Andy', | |
| surname: 'Smith', | |
| email: '', | |
| phone: '', | |
| date: '1979-09-09' | |
| }, | |
| didInsertElement() { | |
| this._super(...arguments); | |
| // If you want to listen for the form becoming valid/invalid | |
| const form = document.querySelector('ns-form'); | |
| form.addEventListener('validated', (event) => { | |
| console.log(event); | |
| this.set('isValid', event.detail.validation.isValid); | |
| if(event.detail.validation.isValid) { | |
| alert('Form is valid'); | |
| } | |
| }); | |
| }, | |
| actions: { | |
| changeDate() { | |
| this.model.date = '2020-12-25'; | |
| }, | |
| submitForm() { | |
| const form = document.querySelector('ns-form'); | |
| const formData = form.validate(); | |
| debugger; | |
| // If you want to scroll to the first invalid field | |
| const invalidFields = formData.fields.filter(field => { | |
| return !field.isValid; | |
| }); | |
| } | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "version": "0.15.1", | |
| "EmberENV": { | |
| "FEATURES": {} | |
| }, | |
| "options": { | |
| "use_pods": true, | |
| "enable-testing": false | |
| }, | |
| "dependencies": { | |
| "nucleus": "https://www.britishgas.co.uk/nucleus/nucleus.min.js?qywytytw", | |
| "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": "3.4.2" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment