-
Notifications
You must be signed in to change notification settings - Fork 0
ChatRoom Flow
kai edited this page Jan 9, 2018
·
8 revisions
local Thin server
bundle exec rackup private_pub.ru -s thin -E production
$ctrl.openRoom = function(room){ $rootScope.$broadcast("chatroom:ready", {room: room}); }
object data="{{$ctrl.baseUrl}}/messages"
$ctrl.baseUrl = UserService.baseUrl;
in routes
resources :messages, module: 'chatroom'
GET /messages def index @messages = Message.all end
in index.html
<%= render "chatroom/messages/chatroom"
<%= show_communications(@messages).html_safe %>
messagehelper.rb
def show_communications(msgs=nil)
div class= container
say card-body
#{sanitize(msg.try(:html_content), tags: %w(br img span p i b a), attributes: %w(id class style src))}
https://www.w3schools.com/jquery/sel_id.asp
$("#intro")
the following are equilvant statements
$("html, body").animate({scrollTop: $("#chat")[0].scrollHeight}, "slow");
$("html").animate({scrollTop: $("#chat")[0].scrollHeight}, "slow");
no animation
$("html, body").scrollTop($("#chat")[0].scrollHeight);
$("html").scrollTop($("#chat")[0].scrollHeight);
# body does not scroll
$("body").scrollTop($("#chat")[0].scrollHeight);