Guest User

Untitled

a guest
Mar 22nd, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. <aura:application extends="force:slds">
  2. <form aura:id="form" target="iframe" action="#" onkeypress="{!c.blockEnter}">
  3. <lightning:input type="text" label="Name" name="name" />
  4. <lightning:button label="Add to Autocomplete" iconName="utility:save" onclick="{!c.saveAutoComplete}" />
  5. </form>
  6. <iframe id="iframe" name="iframe" class="slds-hidden" />
  7. </aura:application>
  8.  
  9. ({
  10. blockEnter: function(component, event, helper) {
  11. if(!component.get("v.allowed")) {
  12. if(event.which === 13) {
  13. event.preventDefault();
  14. }
  15. }
  16. },
  17. saveAutoComplete: function(component, event, helper) {
  18. component.set("v.allowed", true);
  19. component.find("form").getElement().submit();
  20. component.set("v.allowed", false);
  21. }
  22. })
Add Comment
Please, Sign In to add comment