Wednesday, 15 May 2013

javascript - trying to include a .js.erb file into a view -


I am testing to include some js.erb scripts in my view. Just because I'm coding a poll based chat, I want to keep it really simple, but in fact it's actually something more complex, which I initially thought.

Here is my jsk script code:

  $ (document) .ready (function () {$ (function () {setTimeout (updateMessages, 1000);}) ; Function update message () {var game_id = $ ("# game_chat" "(" data-id "); $ (" # message "). Html (" & lt;% = escape_javascript (render (: partial = & gt; ; 'Message'))% setTimeout (Update Message, 1000);}});   

and partially my only

 < Code> & lt;% = render @ message% & gt;   

I actually stuck here and it seems that there is no easy way to include .jserb code inside the view. I mean something It is as follows:

  & lt;% = javascript_include_tag "games / messages.js.erb"%>    

Well you do not need .jserb if you are using the property pipeline. & Lt;% = javascript_include_tag "games / messages"%> Inclination (the engine that decides to use the template engine) will start correctly and will work back like a browser and in fact only see the .js file. It is being said that by doing this you can expect yourself to be completely frustrated with JS perspective. When you include a large string like it is going to trigger an axle on your code. It's okay if you can count 100% on your source, but if you are not careful then open yourself on XS.

No comments:

Post a Comment