English 中文(简体)
如何从铁路主计长那里触发 j印?
原标题:How to trigger javascript from Rails Controller?

在铁路3中,我想触发一条 j,在用户点击链接以加入一个确定用户是否有资格加入的小组后显示出人满为患(控制人员行动确定他们是否合格)。

我需要把id带给控制器,接收控制器的电文,然后使用电文触发 j。

我可以拿 j子触发。 谁能帮助我看一看我谁错了? 我认为,这符合这一联系。

controller action:

def join
  @group = Group.find(params[:id])

if ineligible
  @message = "Sorry, you can t join." 

elsif current_user
  if !@group.already_joined(current_user)
    @message = GroupUser.create(@group,current_user,nil,nil)
  else
    @message = "You re already registered for this group"
  end

else      
  @message = "If you re already a user, but not a member of this group, please login, and then click the join link again.  If you aren t a user yet, please join!"
end
end

javacript

<%= javascript_include_tag "jquery" %>    

<script>
  $(#message).msg( <% @message %> , {
  type :  confirm 
  });  
</script>

意见

<%= link_to  Join ,{:onclick => {:controller =>  groups , :action =>  join , :id => @group.id} }%>
<div id="message"></div>
问题回答

摘录<代码>#message 引文中的选择:

<%= javascript_include_tag "jquery" %>    

<script>
  $( #message ).msg( <% @message %> , {
  type :  confirm 
  });  
</script>




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签