Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在php(jquery插件)中将onclick事件添加到treeview?_Php_Treeview_Events - Fatal编程技术网

如何在php(jquery插件)中将onclick事件添加到treeview?

如何在php(jquery插件)中将onclick事件添加到treeview?,php,treeview,events,Php,Treeview,Events,我已经在php中实现了一个异步,现在我想将onclick事件添加到treeview中的项中,然后在mysql中进行查询 你知道怎么做吗 非常感谢 编辑: Async.html: <script type="text/javascript"> $(document).ready(function(){ $("#black").treeview({ url: "twodimen.php" }); $("#black > li").live("

我已经在php中实现了一个异步,现在我想将onclick事件添加到treeview中的项中,然后在mysql中进行查询

你知道怎么做吗

非常感谢

编辑:

Async.html:

<script type="text/javascript">
$(document).ready(function(){
    $("#black").treeview({
        url: "twodimen.php"
    });
    $("#black > li").live("click",function()){
        $.get("");
    })
});
</script>

<ul id="black">
</ul>

$(文档).ready(函数(){
$(“#黑色”)。树视图({
url:“twodimen.php”
});
$(“#black>li”).live(“单击”,函数()){
$.get(“”);
})
});
但是当我添加
$(“#black>li”).live(“click”,function()){}
时,树视图不会显示


怎么做

好吧,这将是一个开始:

$("#treeview > li").click(function() { // this sets the onclick on your node
    $.get('url_to_php_script_that_will_the_db'); // this calls an url using GET.
    $.post('url_to_php_script_that_will_the_db'); // this calls an url using POST.
}

假设您的treeview具有id“treeview”,则treeview下的所有
都将有一个单击事件。这是一个艰难的开始,但这基本上就是你想要的。

@raceback,请查看我的编辑。我已经更改了我的代码,但我不知道如何做以下事情。你能发布你的整个treeview代码吗?据我所见,可能是'ul>li'选择器发生冲突,但我需要更多的了解。您的树视图的id为='black',请尝试以下操作:$(“#black>li”)。单击(函数(){alert(“CLICKED!!!”);});我还举了一个例子,见这里。对于作者网站上提供的第一个示例,我在treenode上添加了onClick事件。将警报()替换为Ajax调用,使用$.get()或$.post(),而不是两者;)@但是,即使我使用$(“#black>li”).live(“click”,function(){}),树视图也不会显示。只有当我手动添加一个
  • sometext
  • 时,它才会弹出一个警报。若我从数据库生成它,它不会显示。你知道为什么吗?我尝试使用$.get()或$post()。