How to make a DataView control respond to javascript events?

If I had an ASP.NET 4.0 DataView control that looked below, how can I manage client side javaScript events?

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 example, I want a button or a link to "select" this record and send the server an e-mail or mark them in a database or even something as simple as changing the style of a selected row to bring the user focuses on it.

+4
source share
1 answer

AFAIK client templates are used for rendering and do not have any parameters for adding events.

I assume that with jQuery you can implement a simple choice

 $('#peopleList > li').live('click', function () { $(this).parent().children().removeClass('selected'); $(this).addClass('selected'); }); 

The case with the button can be processed by adding it through the client template and linking the events in the same way.

+1
source

Source: https://habr.com/ru/post/1286024/


All Articles