0

我有这个制作按钮的脚本...我需要制作另一个脚本来跟踪单击按钮的时间...我将如何创建它。

 <script id="navTemplate" type="text/x-jquery-template">
{{if TotalItemCount==0}}<br/>No Matches.  Make sure your Marketing Info is complete.
{{else}}
<a href="#" class="rowSelectionPage" data-select="{{if AnyPageHasSelections}}false{{else}}true{{/if}}" data-selectmode="All" data-selectpageurl="PowerMatchingRowSelectionPage" >{{if AnyPageHasSelections}}un{{/if}}select entire list</a> / <a href="#" class="modalEdit" data-mode="send" data-bulkselectionmode="ServerSideRowSelections" data-method="GET" data-successmessage="Message Submitted" data-modalWidth="665" data-viewurl="/Marketing/Email/SendBuyerMatchesEmail?mode=ServerSideRowSelections&sellerId=${CaseId}" data-title="Send Email" title="Send New Email">email selected buyers</a><br />
{{/if}}

4

1 回答 1

1

看来您正在使用一些框架进行绑定。在不知道具体是哪一个的情况下,我只能提供可能有一个内置的事件绑定。例如,在 AngularJS 中有一个“ng-click”指令,它有助于将函数绑定到标准 JavaScript 事件。

在没有这样一个框架的情况下,我同意 Zeaklous。您应该能够将“onClick”事件直接添加到您的锚标记。

<a href="#" onClick="my_tracking_function()" class="rowSelectionPage" data-select="{{if AnyPageHasSelections}}false{{else}}true{{/if}}" data-selectmode="All" data-selectpageurl="PowerMatchingRowSelectionPage" >{{if AnyPageHasSelections}}un{{/if}}select entire list</a>

<script>
      function my_tracking_function() {
           // Trigger some tracking event (i.e. ajax, count...)
      }
</script>
于 2013-07-18T17:44:14.063 回答