2013-07-18 55 views
0

我有这个脚本,使一个按钮...我需要制作另一个脚本,跟踪点击按钮时,我将如何创建该脚本。jquery模板按钮点击?

<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}} 

+0

我在任何地方都看不到'

+0

以及它的一个锚标签。所以当这个锚标签被点击时,我需要跟踪何时发生。 –

+1

做一些关于JavaScript事件的研究。 – pmandell

回答

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>