使用facebox提交表单 [英] using facebox to submit a form
问题描述
我有,我要撒一些ajaxiness到轨工作的应用程序。
I have a working app in rails that I want to sprinkle some ajaxiness to.
我现在有一个多步的形式,并希望做到以下几点:
I currently have a Multistep form and want to do the following:
- 在用户上的步骤1单击提交(表单被提交)
- 的fancybox启动显示注册表单和注册或跳过按钮
- 在不要紧,如果注册或跳过被点击的花式框,用户移动到第2步我的应用程序。
我在寻找推出的fancybox的形式提交
和提交通过的fancybox形式
在演示的我什么也没找到。
In the demo's I found nothing.
在我去的fancybox,已经有人做了使用插件的fancybox这个工作流程?
Before I go with fancybox, has someone done this workflow using the fancybox plugin?
我读了一些<一href="http://stackoverflow.com/questions/969522/open-fancybox-or-equiv-from-form-input-type-submit">SO问题具有提交表单问题的用户。是否有我提到的工作流程?
I read some SO questions with users having issues submitting forms. Is there a better plugin for the workflow I mentioned?
推荐答案
我已经做了与的fancybox类似的实现。我有这样的点击后结账,一个的fancybox会出现一个问题,提示用户结帐。在展示的提示,将提交表单。这是我使用的code轮廓:
I have done an implementation similar with fancybox. I had a user checkout that upon clicking checkout, a fancybox would appear with a question prompt. Before showing the prompt it would submit the form. This is an outline of the code that I used:
我改变表单提交按钮链接:
I change the form submit button to a link:
<a id='various2' href='#submitform'>Submit</a>
绑定的fancybox的链接,添加的onComplete尽快处理形式的fancybox打开:
Bind fancybox to the link and add an oncomplete to process the form as soon as fancybox opens:
$(document).ready(function() {
$("#various2").fancybox({
'cache' : false,
'hideOnOverlayClick' : false,
'showCloseButton' : false,
'autoDimensions' : false,
'width' : 650,
'titlePosition' : 'inside',
'transitionIn' : 'fade',
'transitionOut' : 'fade',
'scrolling' : 'no',
'onComplete' : function(){
processform();
}
});
});
有一个JavaScript函数中使用AJAX来处理表单,然后显示登录/创建帐户信息。如果是我,我会做另一个Ajax调用,以显示你的登录/注册,但我已经离开的code出了一部分,但表示有意见,你可以把它叫做:
Have a javascript function to process the form using ajax and then display your login/create account information. If it were me I would do another ajax call to display your login/signup but I have left that part of the code out but denoted with a comment where you can call it:
function processform(){
var idcardnumber1 = jQuery("#field1").val();
var idcardnumber2 = jQuery("#field2").val();
$.ajax({
cache : false,
type: "POST",
url: "processform.php",
data: "field1="+field1+"&field2="+field2,
dataType: "json",
success: function(data){
if(data.valid == 1){
// Display Your Login Signup Form
}
else{
// Close Fancybox since the form did not submit
$.fancybox.close();
}
}
});
}
这篇关于使用facebox提交表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!