I have a little javascipt script to determine a users GMT timezone offset... is it possible to use that variable in ruby code, in the view? js script: <script type="text/javascript"> Now = new Date(); tzOff = Now.getTimezoneOffset(); tzOff = tzOff/60; </script> Thanks! -stirman -- Posted via http://www.ruby-forum.com/.
Jason Stirman wrote:> I have a little javascipt script to determine a users GMT timezone > offset... is it possible to use that variable in ruby code, in the view? > > > js script: > > <script type="text/javascript"> > Now = new Date(); > tzOff = Now.getTimezoneOffset(); > tzOff = tzOff/60; > </script> > > Thanks! > -stirmanNot directly, in as much as the ruby is executed on the server when the page is served, and the JS is executed on the client. You can sort of merge the two by doing RJS, which is ruby code that generates javascript. ie the Ruby is ultimately executed on the client instead of the server. A, -- Posted via http://www.ruby-forum.com/.
Jason Stirman wrote:> I have a little javascipt script to determine a users GMT timezone > offset... is it possible to use that variable in ruby code, in the view? > > > js script: > > <script type="text/javascript"> > Now = new Date(); > tzOff = Now.getTimezoneOffset(); > tzOff = tzOff/60; > </script> > > Thanks! > -stirmanJavascript is only executed after the render is finished. So the only way is to post an Ajax request with the content you want back to the server, like on page load or something. -- Posted via http://www.ruby-forum.com/.
Got it, thanks!> Javascript is only executed after the render is finished. So the only > way is to post an Ajax request with the content you want back to the > server, like on page load or something.-- Posted via http://www.ruby-forum.com/.