Created
January 12, 2017 00:03
-
-
Save anonymous/fcf2e7aee13d3d9f8cc2e125c5c9174b to your computer and use it in GitHub Desktop.
How to get the event target?
This file contains 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="data" type="List"/> | |
<aura:handler name="init" action="{!c.initHandler}" value="{!this}"/> | |
<aura:iteration items="{!v.data}" var="dataRow"> | |
<li> | |
<a onclick="{!c.iterationHandler}" data-object="{!dataRow.stringified}">Item {!dataRow.Name}</a> | |
</li> | |
</aura:iteration> | |
</aura:component> |
This file contains 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
({ | |
initHandler: function(cmp) { | |
var data = [ | |
{'stringified': '{}', 'Name': 'Red Sox'}, | |
{'stringified': 'true', 'Name': 'White Sox'}, | |
{'stringified': '"foo"', 'Name': 'Giants'}, | |
{'stringified': '[1, 5, "false"]', 'Name': 'Yankees'} | |
]; | |
cmp.set('v.data', data); | |
}, | |
iterationHandler: function(cmp, event) { | |
var valueObject = JSON.parse(event.target.getAttribute('data-object')); | |
console.log(valueObject); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is still not working :/