我试图将两个变量传递给一个有2个参数的预写函数。其思想是,当用户单击过滤器变量1时,设置变量1,然后当他们单击项目变量2时,设置变量2。一旦他们点击一个项目,它就会将两个变量设置为预先编写的函数中的参数(我无法访问更改该函数)。
HTML过滤器:<a href="#" data-filter="*" class="current filter">All</a>
<a href="#" data-filter=".filter1" class="filter">filter1</a>
<a href="#" data-filter=".filter2" class="filter">filter2</a>
<a href="#" data-filter=".filter3" class="filter">filter3</a>
HTML链接: <a data-track="Track Var Link1" href="link1.aspx">Link 1</a>
<a data-track="Track Var Link2" href="link2.aspx">Link 2</a>
<a data-track="Track Var Link3" href="link3.aspx">Link 3</a>
金桥:
var filterText = 'all';
var trackText = '';
$('a.filter').click(function(event) {
filterText = $(this).data('filter');
});
$('.item a').click(function(event) {
trackText = $(this).data('track');
});
$('.item a').click({param1: filterText, param2: trackText}, preWrittenFunction);
Pre-Written-Function:
function preWrittenFunction(type, lname) {
s = s_gi(s_account);
s.linkTrackVars = 'prop5,prop17,prop18,pageName'
s.linkTrackEvents = 'None';
s.prop5 = document.URL.toLowerCase(); // url
s.prop17 = s.pageName; // name and campaign pathing
s.prop18 = type; // widget type
s.tl(this, 'o', type + ": " + lname); // link name includes type
}
将对preWrittenFunction
的调用封装在一个匿名函数中,用作click
事件处理程序:
$('.item a').click(function() {
preWrittenFunction(filterText, trackText);
});