0

我有一个对话框弹出,它使用 YUI 库发布一个表单,到目前为止它正在工作。但是表单提交成功后如何调用另一个函数。我基本上需要从刚刚由表单提交创建的数据库表行中提取一个字段。

到目前为止,这是我的代码:

 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);
4

1 回答 1

0

我相信这个页面包含答案:http: //developer.yahoo.com/yui/container/dialog/

向下滚动到标题为“提交表​​单数据”的部分。它显示了如何配置回调。

于 2013-03-07T18:37:50.147 回答