i'm having trouble grasping how deal front end events in volt, , specific question enlighten me.
i implemented simple chat program webcast , wanted build on it. want chat window stay scrolled bottom chat window populated. think key jquery .animate({ scrolltop:...}) method, don't understand how implement in volt. enlighten me?
my first attempt "scroll_bottom" method in controller https://github.com/mmattthomas/chat/blob/master/app/main/controllers/main_controller.rb#l30-l36
def scroll_bottom ` var newscrollheight = $('.panel-body').attr('scrollheight') - 20; //alert('newscrollheight:' + newscrollheight); $('.panel-body').animate({ scrolltop: newscrollheight }, 'normal'); ` end the javascript runs, variable returns nan.
view here: https://github.com/mmattthomas/chat/blob/master/app/main/views/main/index.html
even specific example doesn't solve whole problem (what if else adds chat, event can animate chat window bottom?) - how best implement client-side action volt?
well, 1 thing know volt uses opalrb client-side workings. run jquery in volt, think easiest use opal wrapper, allow access of libraries jquery ruby.
using opal-jquery wrapper, implement jquery animation so:
panel_body = element.find(".panel-body") panel_body.animate({ scrolltop: panel_body.children.height }, speed: "normal") edit:
here fork of project have implemented fix issue can check out.
Comments
Post a Comment