Skip to Content
Phoenix Web Development
book

Phoenix Web Development

by Brandon Richey
April 2018
Beginner to intermediate content levelBeginner to intermediate
406 pages
9h 33m
English
Packt Publishing
Content preview from Phoenix Web Development

Moving the channel functionality to show

The next step in polishing up our application is moving our channel logic to instead be poll-specific instead of all sitting in the lobby. Open up show.html.eex and change the template to include the WebSocket-specific code that used to live in index.html.eex. We'll need to modify it slightly as well since we'll need to have a way to tell JavaScript what poll ID it needs to use to find the right topic:

<i id="enable-polls-channel" data-poll-id="<%= @poll.id %>"></i><button id="polls-ping" class="btn btn-primary">Ping Websocket</button>

We'll also need to open up socket.js and change the code to start using this new code. Modify the old if statement that checked if polls were enabled for that page to ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Phoenix in Action

Phoenix in Action

Geoffrey Lessel
Real-Time Phoenix

Real-Time Phoenix

Stephen Bussey

Publisher Resources

ISBN: 9781787284197Supplemental Content