回发发生时触发jQuery脚本 [英] Fire jQuery script when postback occurs
本文介绍了回发发生时触发jQuery脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在从.net用户控件后面的代码中注入此jQuery代码...我发现可以使用AJAX来完成jQuery的此应用程序...我仍在做回发...我很好奇我如何能够在页面上有任何更改而不必注入时如何执行此代码?
I've been injecting this jQuery code from the code behind of a .net user control... It has occurred to me that this application of jQuery could have been accomplished using AJAX... I'm still doing a postback... I'm curious as to how I might be able to get this code to execute whenever there is a change on the page and not have to inject?
Protected _picklistColorScriptText As String = "$(document).ready(function(){ " + _
"$('[id ^= ""usrControl""]:visible:disabled').css(""background-color"", '#DCDCDC'); " + _
"$('[id ^= ""usrControl""]:visible:enabled').css(""background-color"", '#FFFFFF');" + _
"});"
推荐答案
将JS/jQuery代码放在pageLoad函数中,而不是(document).ready放在html中,而不是在后面的代码中. pageLoad将在所有回发上触发.
Put the JS/jQuery code in the pageLoad function instead of (document).ready in the html instead of in the code behind. pageLoad will fire on all postbacks.
function pageLoad(){
jQuery here...
}
这篇关于回发发生时触发jQuery脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文