If I had an ASP.NET 4.0 DataView control that looked like below, how can I control javaScript events on the client side?
如果我有一个如下所示的ASP.NET 4.0 DataView控件,我该如何控制客户端的javaScript事件?
Body tag:
<body xmlns:sys="javascript:Sys" xmlns:dataview="javascript:Sys.UI.DataView"
sys:activate="*">
DataView tag:
<ul sys:attach="dataview" dataview:data="{{ ListOfPeople }}" class="sys-template">
<li>
<div>{{ GivenName }}</div>
<div>{{ SurName }}</div>
<div>{{ Title }}</div>
<div>{{ Department }}</div>
<div>{{ Phone }}</div>
<div>{{ EmailAddy }}</div>
</li>
</ul>
For instance, I want a button or link to 'select' this record and have the server send them an email or flag them in the database or even something as simple as changing the style of the selected row so as to bring the user's focus to it.
例如,我想要一个按钮或链接来“选择”此记录,并让服务器向他们发送电子邮件或在数据库中标记它们,甚至可以像改变所选行的样式一样简单,以便将用户的注意力集中到它。
1 个解决方案
#1
AFAIK the client templates are used rendering and do not have any options to attach events.
AFAIK客户端模板用于渲染,没有任何附加事件的选项。
I guess using jQuery you could implement a simple selection
我想使用jQuery你可以实现一个简单的选择
$('#peopleList > li').live('click', function () {
$(this).parent().children().removeClass('selected');
$(this).addClass('selected');
});
The case with the button can be handled by adding it through the client template and binding the events in a similar way.
可以通过客户端模板添加按钮并以类似方式绑定事件来处理按钮的情况。
#1
AFAIK the client templates are used rendering and do not have any options to attach events.
AFAIK客户端模板用于渲染,没有任何附加事件的选项。
I guess using jQuery you could implement a simple selection
我想使用jQuery你可以实现一个简单的选择
$('#peopleList > li').live('click', function () {
$(this).parent().children().removeClass('selected');
$(this).addClass('selected');
});
The case with the button can be handled by adding it through the client template and binding the events in a similar way.
可以通过客户端模板添加按钮并以类似方式绑定事件来处理按钮的情况。