Last active
May 1, 2018 13:00
-
-
Save sohalloran/9d2c6b53cf8fe510ba61a27a86e48b28 to your computer and use it in GitHub Desktop.
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
<aura:application extends="force:slds"> | |
<lightning:card title="bubbleApp"> | |
<c:bubbleGrandParent/> | |
</lightning:card> | |
</aura:application> |
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
<aura:component> | |
<aura:attribute name="message" type="String" default="Hi!"/> | |
<aura:attribute name="result" type="String"/> | |
<aura:registerEvent name="bubbleEvent" type="c:bubbleEvent"/> | |
<aura:handler name="bubbleEvent" event="c:bubbleEvent" action="{!c.showMessage}"/> | |
<lightning:layout verticalAlign ="center"> | |
<lightning:layoutItem padding="around-large"> | |
<lightning:input type="Text" name="message" label="message" value="{!v.message}"/> | |
</lightning:layoutItem> | |
<lightning:layoutItem padding="around-large"> | |
<lightning:button label="OK" onclick="{!c.sendMessage}"/> | |
</lightning:layoutItem> | |
<lightning:layoutItem padding="around-large"> | |
Child: <ui:outputText value="{!v.result}"/> | |
</lightning:layoutItem> | |
</lightning:layout> | |
</aura:component> | |
({ | |
sendMessage : function(component, event, helper) { | |
console.log('send'); | |
component.getEvent('bubbleEvent').setParams({'message':component.get('v.message')}).fire(); | |
}, | |
showMessage : function(component, event, helper) { | |
component.set('v.result',event.getParam('message')); | |
}, | |
}) |
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
<aura:component > | |
<aura:attribute name="result" type="String"/> | |
<aura:handler name="bubbleEvent" event="c:bubbleEvent" action="{!c.showMessage}"/> | |
<lightning:layout verticalAlign ="center"> | |
<c:bubbleParent/> | |
GrandParent: <ui:outputText value="{!v.result}"/> | |
</lightning:layout> | |
</aura:component> | |
({ | |
showMessage : function(component, event, helper) { | |
component.set('v.result',event.getParam('message')); | |
}, | |
}) |
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
<aura:component > | |
<aura:attribute name="result" type="String"/> | |
<aura:handler name="bubbleEvent" event="c:bubbleEvent" action="{!c.showMessage}"/> | |
<lightning:layout verticalAlign ="center"> | |
<c:bubbleChild/> | |
Parent: <ui:outputText value="{!v.result}"/> | |
</lightning:layout> | |
</aura:component> | |
({ | |
showMessage : function(component, event, helper) { | |
component.set('v.result',event.getParam('message')); | |
}, | |
}) |
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
<aura:event type="COMPONENT"> | |
<aura:attribute name="message" type="String"/> | |
</aura:event> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment