2013-07-18 145 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>