当用户右键单击 GridView 的行并且 GridView 在 UpdatePanel 中时,我使用下面的 JavaScript 代码显示列表。发生回发时,它不会显示列表。
$(document).ready(function () {
//--------------- Info Box --------------------
$('.CityItem').mouseup(function (e) {
if ( e.which === 3 ) {
$('.CityItem').children('.CompanyList').hide();
$(this).children('.CompanyList').toggle();
$(this).children('.CompanyList').css('top', e.pageY - 300 );
$(this).children('.CompanyList').css('left', e.pageX - 175 );
}
e.preventDefault();
});
$('.CityItem').hover( function () {
$(this).children('.CompanyList').hide();
});
});
最佳答案
// Attach a handler to the load event.
Sys.Application.add_load(applicationLoadHandler);
将处理程序(上面的代码)放在 updatePanel 中。然后 applicationLoadHandler 将在更新面板刷新时执行。
function applicationLoadHandler() {
//--------------- Info Box --------------------
$(document).on('mouseup', '.CityItem', function (e) {
if ( e.which === 3 ) {
$('.CityItem').children('.CompanyList').hide();
$(this).children('.CompanyList').toggle();
$(this).children('.CompanyList').css('top', e.pageY - 300 );
$(this).children('.CompanyList').css('left', e.pageX - 175 );
}
e.preventDefault();
});
$(document).on('hover', '.CityItem',function () {
$(this).children('.CompanyList').hide();
});
}
关于javascript - 回发后不显示我在 JavaScript 中右键单击显示的列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19354260/