php返回无法正常工作的thickbox链接 [英] Php returns thickbox link that doesn't work

查看:62
本文介绍了php返回无法正常工作的thickbox链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试返回一个链接以从简单的php echo提取页面上的thickbox时,我遇到了一个问题.基本上我拥有的是:

I'm running into a bit of an issue when I try to return a link to pull up a thickbox on my page from a simple php echo. Basically what I have is:

一个包含一些include语句的页面,例如:

A page with a few include statements like:

<?php 
    include ("display_header.php");
?>

其中一个include语句仅指向一个php文件,该文件会拉出简短的查询,并在用户单击链接文本时,通过锚定引用回显一个链接,以打开内联thickbox(带有表单),如下所示:

Each one of the include statements just points to a php file that pulls a short query and echos out a link with an anchor ref to open an inline thickbox (with a form) when the user clicks on the link text like:

echo "<a href='#TB_inline?height=265&width=225&inlineId=header_change' class='thickbox' style='text-decoration:none; color:#990000'>";
echo "Query Result etc";
echo "</a>";

因此,当用户单击页面上的链接时,应该弹出带有表单的厚框.用户输入对给定部分的更改,单击提交,然后jquery ajax发布表单,并使用include语句重新加载div以显示更改.

So when the user clicks on the link on the page, a thickbox with a form is supposed to pop up. The user enters their changes to the given section, clicks submit, and jquery ajax posts the form and reloads the div with the include statement to display the changes.

这在第一次加载页面时有效,但是一旦我提交了表单并尝试再次单击返回的链接,便没有任何反应.如果我的链接在div中用include语句括起来(这没什么大不了的话),这似乎可行(但是没什么大不了的),但是我只是不明白为什么如果我在include中包含了链接,为什么这不起作用php语句.

This works the first time the page is loaded, but once I submit the form and try to click on the returned link again nothing happens. This seems to work if I have the link surround the div with the include statement inside (which isn't a big deal to do), but I just don't understand why this doesn't work if I have the link in the included php statement.

有人可以提供一些指导吗?我知道这里有很多才华横溢的人,我可能只是不了解一些非常基础的知识.谢谢!

Can anyone offer some guidance? I know there are a lot of brilliant people here and I'm probably just not understanding something very basic. Thanks!

推荐答案

您需要使用

这将防止启用了启用thickbox的链接在通过ajax重新加载或注入后失去与thickbox的绑定.

That will prevent your thickbox enabled links from losing their binding to thickbox after they are reloaded or injected via ajax.

您也可以在$ .ajax(或$ .post或其他方法)的回调中完成此操作,例如:

You can also do it in the callback to your $.ajax (or $.post or whatever) method, e.g.:

$.ajax({
    type:       "GET",
    url:        "/ajax-content.php",
    cache:      false,
    data:       "f=foo&b=bar",
    loading:    $('.loading').html(''),
    success:    function(html) {
                    $('#ajaxContent').html(html);
                    //re-attach thickbox
                    tb_init('a.thickbox, area.thickbox, input.thickbox');
                }
});

这篇关于php返回无法正常工作的thickbox链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆