Facebox 仅在首次提交 Jquery 表单时打开一次
我有一个仪表板页面,用户可以在其中输入要搜索的资产代码或 ID,然后单击搜索按钮或按 Enter 键,搜索结果会出现在 Facebox 模式中。到目前为止,一切都很好。但是,当用户尝试执行第二次搜索时,尽管 JQuery POST 正确发生并且响应 HTML 按应有的方式返回,但 Facebox 结果模式无法打开。我的绑定到提交函数并执行 ajax POST 的函数如下:
// attach a submit handler to the form
$("#astsrch").submit(function(event) {
//$('a[rel*=facebox]').facebox();
// stop form from submitting normally
event.preventDefault();
// get some values from elements on the page:
var $form = $( this ),
term = $form.find( 'input[name="assetsearch"]' ).val(),
url = $form.attr( 'action' );
// Send the data using post and put the results in a div
$.post( url, { assetsearch: term } ,
function( data ) {
$.facebox(data);
}
);
});
当单击 Facebox 关闭按钮时,似乎发生了一些事情,阻止了通过上述函数提交搜索表单时进一步打开 Facebox。
I have a dashboard page where the user can enter an asset code or ID to search on, and on clicking the search button or hitting enter the search result comes up in a Facebox modal. So far, so good. However, when the user tries to perform a second search, the Facebox result modal fails to open, despite the JQuery POST happening correctly and the response HTML being returned as it should be. My function that binds to the submit function and performs the ajax POST is as follows:
// attach a submit handler to the form
$("#astsrch").submit(function(event) {
//$('a[rel*=facebox]').facebox();
// stop form from submitting normally
event.preventDefault();
// get some values from elements on the page:
var $form = $( this ),
term = $form.find( 'input[name="assetsearch"]' ).val(),
url = $form.attr( 'action' );
// Send the data using post and put the results in a div
$.post( url, { assetsearch: term } ,
function( data ) {
$.facebox(data);
}
);
});
It seems that something is happening when the Facebox close button is clicked that prevents any further Facebox from opening when the search form is submitted via the above function.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看这个帖子。它和你的很相似。尝试在提交按钮上绑定点击事件。
比如:
祝你好运!
look at this post. it's similar to yours. try to bind a click event on the submit button.
something like:
good luck!