English 中文(简体)
B. 未在铁路作业的侵扰性 Java
原标题:Unobtrusive JavaScript not working in Rails 3 app

试图在我的网站上添加组合式编码。 然而,我无法在铁路3号车上打碎机,以追踪我在提交表格时发生的事件。 该法典确实是从幼苗的 window窗上运作的。 任何建议? 以下是我html.erb档案中的代码。 这被放在档案的头部,以及从混合体获得的 j印。

    <% javascript_tag do %>
      var my_term = <%= strip_tags(@term.to_json) %>
<% end %>

Here s the code that I have in my form to track a submit

<%= form_tag("/search", :method => "get", :onsubmit =>  mpq.track("search",{"term":my_term}); , :style => "float:right;margin-top:9px;") do %>

增 编

Generated js

<script type="text/javascript">
//<![CDATA[
      var my_term = "san francisco"

//]]>
</script>

Generated html

<form accept-charset="UTF-8" action="/search" method="get" onsubmit="mpq.track(&quot;search&quot;,{&quot;term&quot;:my_term});" style="float:right;margin-top:9px;">
最佳回答

贵国法典有两个问题:

页: 1

onsubmit="mpq.track(&quot;search&quot;,{&quot;term&quot;:my_term});" 

页: 1

2 - In some cases, even after fixing the &quot; issue, the event will not fire. This is because the page will change before the call to Mixpanel has a chance to resolve. It would be better just to call mpq.track() on the search page itself, instead of using an onsubmit javascript event.

问题回答

暂无回答




相关问题
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.

热门标签