jQuery的不工作的MultiView [英] Jquery doesn't work with MultiView
问题描述
我有一个多视图这是一个UpdatePanel内内一个div。当我点击的按钮是内部的UpdatePanel进行回调并出现在div,但它不会改变鼠标悬停颜色(jQuery的不工作)。
如果我把格在UpdatePanel外面jQuery的正常工作。
还有什么比这里是什么问题?
感谢您
<脚本SRC =jQuery的-1.5.2.min.js类型=文/ JavaScript的>< / SCRIPT>
< ASP:ToolkitScriptManager ID =ToolkitScriptManager1=服务器>
< / ASP:ToolkitScriptManager>
<脚本类型=文/ JavaScript的>
$(文件)。就绪(函数(){
$(#MyDiv)悬停(函数(){$(本)的.css({'背景色':'红'})})。
});< / SCRIPT>< ASP:的UpdatePanel ID =UpdatePanel1=服务器的UpdateMode =条件>
<&的ContentTemplate GT;
< ASP:多视图=服务器ID =mvPopup>
< ASP:查看ID =视图1=服务器>
< DIV ID =MyDiv>此处的一些文字< / DIV>
< / ASP:视图>
< / ASP:多视图>
< ASP:LinkButton的=服务器的OnClick =btnLink_ClickID =btnLink文本=点击这里/>
< /&的ContentTemplate GT;
< / ASP:的UpdatePanel>保护无效btnLink_Click(对象发件人,EventArgs的发送)
{
mvPopup.ActiveViewIndex = 0;
}
请尝试使用 .live 自股利是不是在页面上时,该文件第一次加载:
$(文件)。就绪(函数(){
$(#MyDiv),生活(悬停功能(){$(本)的.css({'背景色':'红'})});
});
如果你想要做不同的事情后徘徊,试图结合这两个鼠标悬停和鼠标移开:
$('#MyDiv')。生活(鼠标悬停鼠标移开,函数(事件){
如果(event.type =='鼠标悬停'){
//做一些鼠标悬停
}其他{
//做一些鼠标移开
}
});
I have a div inside a MultiView that is inside an UpdatePanel. When I click on the button that is inside UpdatePanel the callback is performed and the div appears, but it doesn't change its color on mouse hover (jquery doesn't work).
If I put the div outside the UpdatePanel jquery works correctly.
What could be the problem here?
Thank you
<script src="jquery-1.5.2.min.js" type="text/javascript"></script>
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<script type="text/javascript">
$(document).ready(function () {
$("#MyDiv").hover(function () { $(this).css({ 'background-color': 'Red' }) });
});
</script>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:MultiView runat="server" ID="mvPopup">
<asp:View ID="View1" runat="server">
<div id="MyDiv">Some text here</div>
</asp:View>
</asp:MultiView>
<asp:LinkButton runat="server" OnClick="btnLink_Click" ID="btnLink" Text="Click here" />
</ContentTemplate>
</asp:UpdatePanel>
protected void btnLink_Click(object sender, EventArgs e)
{
mvPopup.ActiveViewIndex = 0;
}
Try using .live since the div is not on the page when the document first loads:
$(document).ready(function () {
$("#MyDiv").live("hover", function () { $(this).css({ 'background-color': 'Red' }) });
});
If you want to do something different after hovering, try binding to both mouseover and mouseout:
$('#MyDiv').live('mouseover mouseout', function(event) {
if (event.type == 'mouseover') {
// do something on mouseover
} else {
// do something on mouseout
}
});
这篇关于jQuery的不工作的MultiView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!