Skip to content

Instantly share code, notes, and snippets.

@msrivastav13
Last active January 15, 2018 21:13
Show Gist options
  • Save msrivastav13/feef2eee65728d74660ebe49f017302d to your computer and use it in GitHub Desktop.
Save msrivastav13/feef2eee65728d74660ebe49f017302d to your computer and use it in GitHub Desktop.
Code to Show LockerService In action
<aura:application extends="force:slds">
<c:searchCmp />
</aura:application>
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global" >
<aura:attribute name="searchTerm" type="String" />
<lightning:layout multipleRows="true" horizontalAlign="center" verticalAlign="center">
<lightning:layoutItem flexibility="auto" size="6">
<lightning:input type="search" aura:id="searchBox" label="Search" name="search" placeholder="Enter Search Term"/>
</lightning:layoutItem>
<lightning:layoutItem flexibility="auto" size="4" padding="horizontal-small">
<lightning:button variant="brand" label="Search" title="" onclick="{! c.handleClick }" />
</lightning:layoutItem>
<lightning:layoutItem flexibility="auto" padding="around-large" size="6">
<p> You searched for {!v.searchTerm}</p>
</lightning:layoutItem>
</lightning:layout>
</aura:component>
({
handleClick : function(component, event, helper) {
helper.setSearchTerm(component, event);
}
})
({
setSearchTerm : function(component, event) {
var searchTerm = component.find('searchBox').getElement().value;
console.log(searchTerm);
component.set("v.searchTerm",searchTerm);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment