简体   繁体   English

YUI对话框,表单提交成功后进行回调

[英]YUI Dialog, callback after form submit is successful

I have a dialog popup that that posts a form using the YUI library and this is working so far. 我有一个对话框弹出窗口,该对话框使用YUI库发布表单,到目前为止,该对话框仍在工作。 But how do I call another function after the form has been submitted successfully. 但是,成功提交表单后如何调用另一个函数。 I basically need to pull a field from the database table row that was just created by the form submit. 我基本上需要从表单提交刚刚创建的数据库表行中提取一个字段。

Here is my code so far: 到目前为止,这是我的代码:

 var callback = {

    success: function(result) {

        form = result.responseText;

        dialog = new YAHOO.widget.Dialog('dialog1', {
            width: '400px',

            fixedcenter : "contained",
            visible : false,
            draggable: true,
            effect:[{effect:YAHOO.widget.ContainerEffect.SLIDE, duration:0.2},
                    {effect:YAHOO.widget.ContainerEffect.FADE,duration:0.2}],
            modal:true
        });

        dialog.setHeader(titleval);
        dialog.setBody(form);

        var handleCancel = function() {
            this.cancel();

        };
        var handleSubmit = function() {

            date_box = dialog.getData().date;
            reason_box = dialog.getData().reason;
            hours = dialog.getData().date_start_hours;
            mins = dialog.getData().date_start_minutes;
            format = dialog.getData().format;
            ampm = dialog.getData().date_start_meridiem;
            username = dialog.getData().user;

            //basic validation
            if(date_box == '' && reason_box == '' ){

                document.getElementById('error1').style.display = "";
                document.getElementById('error2').style.display = "";

            }else if(date_box == '' || !isDate(date_box)){

                document.getElementById('error1').style.display = "";
                document.getElementById('error2').style.display = "none";

            }
            else if(reason_box == '' && !isDate(date_box)){

                document.getElementById('error1').style.display = "";
                document.getElementById('error2').style.display = "";

            }
            else if(reason_box == ''){

                document.getElementById('error1').style.display = "none";
                document.getElementById('error2').style.display = "";

            }
            else{

                 this.submit();
                 update(date_box, hours, mins, format, ampm, reason_box, username);
            }

        };
        var myButtons = [{ text: "Save", handler: handleSubmit, isDefault: true },
                         { text: "Cancel", handler:handleCancel }];

        dialog.cfg.queueProperty("buttons", myButtons);
        dialog.render(document.body);
        dialog.show();

        document.getElementById('call_id').value = id.value;
        eval(document.getElementById('script').innerHTML);
        eval(document.getElementById('script2').innerHTML);

    }

}

var connectionObject = YAHOO.util.Connect.asyncRequest ("GET", "index.php?entryPoint=Reschedule&call_id="+id.value, callback);

I believe this page contains the answer: http://developer.yahoo.com/yui/container/dialog/ 我相信此页面包含答案: http : //developer.yahoo.com/yui/container/dialog/

Scroll down to the section titled "Submitting Form Data". 向下滚动到标题为“提交表​​单数据”的部分。 It shows how to configure callbacks. 它显示了如何配置回调。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM