Updating the view to subscribe to the event stream

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>
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset