jQuery$(文档).就绪和UpdatePanels?我使用jQuery来连接UpdatePanel中元素的鼠标覆盖效果。这些事件被捆绑在一起$(document).ready..例如:$(function() {
$('div._Foo').bind("mouseover", function(e) {
// Do something exciting
}); });当然,这在第一次加载页面时工作得很好,但是当UpdatePanel执行部分页面更新时,它就不会运行,而mouseover效果在UpdatePanel中不再起作用。在jQuery中,不仅在第一个页面加载时,而且每次UpdatePanel触发部分页面更新时,推荐的连接方法是什么?我是否应该使用ASP.NETAjax生命周期而不是$(document).ready?
3 回答
慕标琳琳
TA贡献1830条经验 获得超9个赞
<script type="text/javascript">
function BindEvents() {
$(document).ready(function() {
$(".tr-base").mouseover(function() {
$(this).toggleClass("trHover");
}).mouseout(function() {
$(this).removeClass("trHover");
});
}</script><asp:UpdatePanel... <ContentTemplate <script type="text/javascript"> Sys.Application.add_load(BindEvents); </script> *// Staff*</ContentTemplate> </asp:UpdatePanel>
慕姐4208626
TA贡献1852条经验 获得超7个赞
在UpdatePanel中使用jQuery的用户控件
<script type="text/javascript">
function BindControlEvents() {
//jQuery is wrapped in BindEvents function so it can be re-bound after each callback.
//Your code would replace the following line:
$('#<%= TextProtocolDrugInstructions.ClientID %>').limit('100', '#charsLeft_Instructions');
}
//Initial bind
$(document).ready(function () {
BindControlEvents();
});
//Re-bind for callbacks
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(function() {
BindControlEvents();
}); </script>添加回答
举报
0/150
提交
取消
