如何在不关闭厚盒的情况下触发事件?
我正在使用thickbox,我需要使用asp 控件,并且还必须调用相应控件的事件。最近我遇到了一个问题,例如,在厚盒中使用时,ASP 控件的事件不会被触发。以下是解决我的问题的分步过程:
我需要从thickbox 触发一个asp 按钮单击事件而不关闭thickbox。
为了解决#1,我使用了以下脚本:
function doPostBack(element) { tb_remove(); setTimeout('__doPostBack(\'' + element.name + '\',\'\')', 500); }
- #2 触发事件并关闭厚盒窗口。我需要在厚盒窗口上显示标签,而关闭窗口则无法实现。
我尝试了 tb_show() 方法来显示 thicbox,但是仅使用 firebug 进行调试时会显示该窗口,并且关闭按钮将不起作用。 任何建议都会有帮助...
I'm working with thickbox where i need to use asp controls and have to call the events of the corresponding controls as well. Recently i faced an issue like, asp control's events are not getting fired when used within the thickbox. Following are the step by step procedure on my issue:
I need to fire an asp button click event from the thickbox without closing the thickbox.
In order to solve #1, i used the following script:
function doPostBack(element) { tb_remove(); setTimeout('__doPostBack(\'' + element.name + '\',\'\')', 500); }
- #2 fires the event and closes the thickbox window. I need to display a label on the thickbox window and closing the window makes it impossible.
I tried the tb_show() method for displaying the thicbox but the window will be displayed while debugging using firebug only and the close button will not work then.
Any suggestions will be helpful...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,一些关于为什么您的原始解决方法是必要的信息。
大多数模式对话框插件(例如 Thickbox)会将包含对话框内容的 div 从其在 DOM 中的原始位置拉出,然后再次将其附加到
body
标记下。这主要与弹出窗口后面的覆盖层正确显示有关。这样做的一个副作用是,您的表单控件不再位于
您在上面找到的解决方法是最简单的解决方案,它首先关闭 Thickbox,以便您的表单内容现在回到 DOM 中
如果您希望 Thickbox 对话框在回发期间保持打开状态,则必须处理上面的实际问题。一种方法是不真正进行回发,而是使用 AJAX 使用表单字段中的值调用 Web 服务/方法。另一种选择是修改thickbox.js 以将所有内容保留在表单标记内。第三种选择是在另一个页面上放置您的表单,然后将其加载到 iframe 中的 Thickbox 内。
无论采用哪种解决方案,它要么涉及将对话框内容保留在 DOM 中的表单标记内,要么使用发布表单数据的替代方法,这样即使它位于表单之外也没关系。
希望这可以帮助您找到适合您具体情况的解决方案。
有关在没有标准链接标签的情况下打开thickbox的原始问题的原始答案
您尝试过以下操作吗?
我不使用 Thickbox,但这是当您单击链接时它在内部使用的函数。
First, some info on why your original workaround is necessary.
Most of these modal dialog plugins, like Thickbox, pull your div that contains the dialog content out of its original place in the DOM, and attach it again under the
body
tag. This mainly has to do with getting the overlay behind the popup to display properly.One side-effect of this, especially in an ASP.NET page where everything is inside only ONE form tag, is that your form controls are no longer within the
<form>
tag. So when you click on the button to submit the form, nothing happens (because it's not inside a form that it can submit).The workaround you found above, which is the easiest solution, closes the Thickbox first, so that your form content is now back in its original position in the DOM, inside the
<form>
tag. Then it initiates the submit of the form. It uses a timeout to make sure the dialog has had a chance to close properly before trying the submit.If you want the Thickbox dialog to stay open during your postback, you have to deal with the real issue above. One way, is to not really do a postback, and instead use AJAX to call a webservice/method with the values from your form fields. Another option is to modify the thickbox.js to keep everything inside the form tag. A third option, is to have another page with your form on it, and then load that inside a Thickbox in an iframe.
Whatever the solution, it will either involve keeping the dialog contents inside the form tag in the DOM, or using an alternative way of posting the form data so that it doesn't matter if it's outside the form.
Hope this helps you find a solution to your specific situation.
Original answer for original question about opening thickbox without a standard link tag
Have you tried the following?
I don't use Thickbox, but this is the function it uses internally when you click on a link.