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

Refactoring for poll chats

We need a way to be able to specify which chatroom to connect to for our polls-specific chat. To do that we'll need to start specifying the chatroom (we'll use that as part of the topic to connect to). We'll start by placing a data attribute on our chat-window in lib/vocial_web/templates/shared/_chat.html.eex that we will reference later in our chat.js file:

<div class="chat-window container well" id="enable-chat-channel" data-chatroom="<%= @chatroom %>">

We'll need to actually pass a value to that that will enable us to reference @chatroom since right now we're not setting that anywhere. We'll also need to hop out to our lib/vocial_web/templates/poll/show.html.eex and set that as part of the call to render:

<%= ...
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