Skip to content

Commit 1a086ba

Browse files
committed
Merge pull request #10 from iurijacob/patch-1
Prevent event duplication
2 parents 00a41eb + 8799a08 commit 1a086ba

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

AjaxSubmitButton.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ protected function registerAjaxScript()
122122
$this->ajaxOptions['data'] = new JsExpression('$(this).parents("form").serialize()');
123123

124124
$this->ajaxOptions= Json::encode($this->ajaxOptions);
125-
$view->registerJs("$('#".$this->options['id']."').click(function() {
125+
$view->registerJs("$('#".$this->options['id']."').unbind('click').click(function() {
126126
" . (null !== $this->clickedButtonVarName ? "var {$this->clickedButtonVarName} = this;" : "") . "
127127
$.ajax(" . $this->ajaxOptions . ");
128128
return false;
@@ -147,7 +147,7 @@ protected function registerAjaxFormScript()
147147
$this->ajaxOptions= Json::encode($this->ajaxOptions);
148148

149149
$js = <<<SEL
150-
$(document).on('beforeSubmit', "#{$this->useWithActiveForm}", function () {
150+
$(document).unbind('beforeSubmit').on('beforeSubmit', "#{$this->useWithActiveForm}", function () {
151151
if ($(this).find('.has-error').length < 1) {
152152
$.ajax({$this->ajaxOptions});
153153
}

0 commit comments

Comments
 (0)