We want to update the view with new buttons to trigger events to list all stocks and show the details of a specific stock. The following snippet shows the code to be added to resourcesstaticstock-price.html:
<button id="list-stocks-button">List All Stocks</button>
<button id="ibm-stock-details-button">Show IBM Details</button>
The following snippet enables click events on the new buttons, trigger connection with their respective events:
<script type="application/javascript">
addEvent("click",
document.getElementById('list-stocks-button'),
function() {
registerEventSourceAndAddResponseTo("/stocks","display");
}
);
addEvent("click",
document.getElementById('ibm-stock-details-button'),
function() {
registerEventSourceAndAddResponseTo("/stocks/IBM","display");
}
);
</script>