而股票更新面板jQuery函数不工作 [英] JQuery Function doesn't work while the ticker Updating the panel
问题描述
为什么JQuery的功能不同时,股票更新面板工作?请参阅下面的code。
Why the JQuery function doesn't work while the ticker Updating the panel? Please see the code below.
<asp:Timer ID="Schedule_Timer" runat="server" Interval="10000"></asp:Timer>
<asp:UpdatePanel ID="Schedule_UpdatePanel" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Schedule_Timer" EventName="Tick" />
</Triggers>
<ContentTemplate>
<asp:Panel ID="Schedule_Panel" runat="server" Height="250px" Width="250px">
<asp:Literal ID="Schedule_Label" runat="server" Text=""></asp:Literal>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
<script>
$('#test').cycle({
fx: 'scrollUp',
timeout: 6000,
delay: -2000
});
</script>
的 Schedule_Label
通过填写$ C $ C-背后:
The Schedule_Label
is filled in via code-behind:
Protected Sub Schedule_Timer_Tick(sender As Object, e As System.EventArgs) Handles Schedule_Timer.Tick
PrintTheSchedule()
End Sub
Private Sub PrintTheSchedule()
//This is just for example, the actual data is taken from gridview based on the realtime
Schedule_Label.Text = "<div id='test'>" & _
"<div>test 1</div>" & _
"<div>test 2</div>" & _
"<div>test 3</div>" & _
"<div>"
End Sub
有关前10秒,JQuery的做骑自行车的测试
DIV。但在UpdatePanel刷新后,再JQuery的已经不运行,它引起的一切测试
DIV值显示在页面上。如何解决这个问题呢?非常感谢你。
For the first 10 seconds, the JQuery do cycling the test
div. But after the UpdatePanel refreshed, then the JQuery doesn't running anymore and it caused all of the test
div value showed up on the page. How to fix this problem? Thank you very much.
推荐答案
有一个preety简单的答案。
There is a preety simple answer.
在页面加载本身只执行jQuery函数。因此,当计时器滴答jQuery函数不会再继续有效。
The jquery function executed on the page load itself only. So when the Timer tick the jquery function does not remain valid again.
所以,你需要做的是:
在PrintTheSchedule功能再次调用javascript函数像
In the PrintTheSchedule function call the javascript function again like
在C#我这样做像
ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "runScript", "RunScriptAgain();", true);
而在aspx页面做
And in the Aspx Page do
<script>
function RunScriptAgain()
{
$('#test').cycle({
fx: 'scrollUp',
timeout: 6000,
delay: -2000
});
}
//必需首次
$(document).ready(function() { RunScriptAgain(); })
这篇关于而股票更新面板jQuery函数不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!