jQuery,只允许一次点击对话框是的按钮

时间:2016-07-16 07:42:22

标签: javascript jquery jquery-ui jquery-plugins jquery-ajaxq

我正在尝试编写一个jQuery对话框,当我点击“确定”按钮时,每次点击它都会发送数据。

所以,无论是多次点击还是一次点击“确定”按钮,我都需要它才能工作一次。

$.dialogue({
                    class: 'big',
                    body: html,
                    yes: {
                        text: 'ok',
                        func: function() {

                            //execute some codes

                    }, //end function
                    },
                    no: {text: 'Cancel'},
                });

1 个答案:

答案 0 :(得分:1)

$.dialogue({
                    class: 'big',
                    body: html,
                    yes: {
                        text: 'ok',
                        func: (function() {
                            var executed = false;
                            return function () {
                            if (!executed) {
                            executed = true;
                            //execute some codes                                                            
                        }
                        };
                    })(), //end function
                    },
                    no: {text: 'Cancel'},
                });
相关问题