麻烦让JQuery在PostBack上运行 [英] Trouble Getting JQuery To Run On PostBack
本文介绍了麻烦让JQuery在PostBack上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
新手在这里
以下是每次在asp.net vb网页上的树视图中单击复选框节点时运行的脚本。脚本工作正常。
我希望每次在我的页面上发生回发时运行相同的脚本。我知道我相信我需要使用这样的东西:
Newbie Here
Below is my script that runs each time a checkbox node is clicked within a treeview on a asp.net vb webpage. The Script works fine.
I would like for this same script to run each time a postback occurs on my page. I know that I believe that I need to use something like this:
ScriptManager.RegisterStartupScript(Me, Page.GetType(), "scriptKey", "somefuncname();", True)
在我的代码背后。 。 。 。但它似乎不起作用
任何帮助表示赞赏
格雷格
On my code behind . . . . but it does not seem to work
Any help is appreciated
Greg
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$(function() {
$("[id*=TreeView2] input[type=checkbox]").bind("click", function () {
var table = $(this).closest("table");
if (table.next().length > 0 && table.next()[0].tagName == "DIV") {
//Is Parent CheckBox
var childDiv = table.next();
var isChecked = $(this).is(":checked");
$("input[type=checkbox]", childDiv).each(function () {
if (isChecked) {
$(this).attr("checked", "checked");
} else {
$(this).removeAttr("checked");
}
});
} else {
//Is Child CheckBox
var parentDIV = $(this).closest("DIV");
if ($("input[type=checkbox]", parentDIV).length == $("input[type=checkbox]:checked", parentDIV).length) {
$("input[type=checkbox]", parentDIV.prev()).attr("checked", "checked");
$("input[type=checkbox]", parentDIV.prev()).prop("indeterminate", false);
} else {
if($("input[type=checkbox]:checked", parentDIV).length == 0) {
$("input[type=checkbox]", parentDIV.prev()).removeAttr("checked");
$("input[type=checkbox]", parentDIV.prev()).prop("indeterminate", false);
}else{
$("input[type=checkbox]", parentDIV.prev()).prop("indeterminate",true);
}
}
}
});
})
});
</script>
推荐答案
( document ) .ready( function (){
(document).ready(function () {
( function () {
( [id * = TreeView2]输入[type = checkbox] )。bind( 点击, function (){
var table =
("[id*=TreeView2] input[type=checkbox]").bind("click", function () { var table =
这篇关于麻烦让JQuery在PostBack上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文