Last active
February 8, 2017 22:33
-
-
Save fayeli/e5a95ca01bd3179ed7f86ec07bab14fa to your computer and use it in GitHub Desktop.
tabletAppTutorialStep5
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
<body> | |
<div class="top-bar"> | |
<h4>Gemstone Magic Maker</h4> | |
</div> | |
<div class="content"> | |
<p>Pick a gemstone from our curated collection:<p> | |
<p><input type="button" class="gemstone-button white" value="Emerald"></p> | |
<p><input type="button" class="gemstone-button red" value="Ruby"></p> | |
<p><input type="button" class="gemstone-button blue" value="Sapphire"></p> | |
<p><input type="button" class="gemstone-button white" value="Quartz"></p> | |
</div> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> | |
<script> | |
function main() { | |
// Send an event to gemstoneApp.js when the page loads and is ready to get things rolling | |
console.log("document ready"); | |
var readyEvent = { | |
"type": "ready", | |
}; | |
// The event bridge handles event represented as a string the best. So here we first create a Javascript object, then convert to stirng | |
EventBridge.emitWebEvent(JSON.stringify(readyEvent)); | |
// Send an event when user click on each of the gemstone buttons | |
$(".gemstone-button").click(function(){ | |
console.log(this.value + " button click"); | |
var clickEvent = { | |
"type": "click", | |
"data": this.value | |
}; | |
EventBridge.emitWebEvent(JSON.stringify(clickEvent)); | |
}); | |
} | |
$(document).ready(main); | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment