Is there any way to access javasript variable inside the rails view. I just set some value of javascript variable and want to access it in rails view.
增 编
Is there any way to access javasript variable inside the rails view. I just set some value of javascript variable and want to access it in rails view.
增 编
你们必须理解,你的看法中的废墟代码在服务器上执行,而网页上的任何 j印都有待执行。
因此,你不能这样做:
<script>
var js_var = 1;
</script>
<%= get_value_of_js_var_somehow %>
其另一轮工作是:
<script>
var js_var = <% generate_value_with_ruby %>;
do_something_in_javascript_with_js_var();
</script>
你们可以向使用AJAX的铁路通过ava形。 举例来说,如果你想将用户的补贴通过到铁路控制器的一种方法中,你就可以执行以下守则:
<script>
var id = 1;
<%= remote_function :url => {:controller=> controller_name , :action=> method_name }, :with => " user_id= + id" %>
</script>
你们将通过作为参数的《组织社会责任倡议》申请获得变量。 用户_id]。
def method_name
if params[:user_id].exists?
u = User.where( id = ? , params[:user_id]).first
end
puts u.path
end
我希望我回答了你的问题。
如果你在较高部分的javascript(本身:申请)中能够变数,那么你总是能够从这个角度看待。
#application.js
var someVar = "Hello World";
然后,在你看来(对客户执行),你可以......
<script type= text/javascript >
alert(someVar);
</script>
我认为,如果这3个员额中有一个没有回答你的问题,我们需要更具体的阐述。
我们有以下文字:
<script type="text/javascript">
var a="some value";
document.getElementById( tagid ).innerHTML= <%= tag(:div,content_tag(:p, " +a+ " ), :id=> " +a+ " , name=>"somename") %> ;
</script>
collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...
We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...
As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...
I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?
I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...
I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml
guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...
I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...