Skip to content

Commit

Permalink
Merge pull request #2 from obisconcept/master
Browse files Browse the repository at this point in the history
Added suggestion
  • Loading branch information
René Zwinge authored Sep 28, 2016
2 parents cc05005 + 508a332 commit 35282f8
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Add the package in your site package composer.json

```
"require": {
"obisconcept/neos-ajax-form": "~1.0"
"obisconcept/neos-ajax-form": "~1.0.0"
}
```

Expand Down
17 changes: 16 additions & 1 deletion Resources/Private/Assets/JavaScript/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ $(document).ready(function() {

});

window.initButtonClickHandler = function() {

$('.ajax-form button[type="submit"]').on('click', function() {
$('.ajax-form button[type="submit"]').removeAttr('clicked');
$(this).attr('clicked', 'true');
});

}

window.initAjaxForm = function() {

$.each($('.ajax-form'), function (idx, ajaxForm) {
Expand All @@ -20,7 +29,9 @@ window.initAjaxForm = function() {
var formURL = formObj.attr('action');
var formData = new FormData(this);

formData.append($(this).find('button[type="submit"]').attr('name'), $(this).find('button[type="submit"]').attr('value'));
var trigger = $(this).find('button[clicked="true"]');

formData.append($(trigger).attr('name'), $(trigger).attr('value'));

$.ajax({

Expand All @@ -40,6 +51,8 @@ window.initAjaxForm = function() {

$(ajaxForm).find('.ajax-content').replaceWith(data);

initButtonClickHandler();

if ($(ajaxForm).find('.g-recaptcha').length) {
var captcha = $(ajaxForm).find('.g-recaptcha');
var sitekey = captcha.data('sitekey');
Expand All @@ -56,6 +69,8 @@ window.initAjaxForm = function() {

$(ajaxForm).load(formAjaxUrl + ' .ajax-content', function () {

initButtonClickHandler();

$(this).css("min-height", $(this).css("height"));

if ($(this).find('.g-recaptcha').length) {
Expand Down
17 changes: 16 additions & 1 deletion Resources/Public/JavaScript/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ $(document).ready(function() {

});

window.initButtonClickHandler = function() {

$('.ajax-form button[type="submit"]').on('click', function() {
$('.ajax-form button[type="submit"]').removeAttr('clicked');
$(this).attr('clicked', 'true');
});

}

window.initAjaxForm = function() {

$.each($('.ajax-form'), function (idx, ajaxForm) {
Expand All @@ -20,7 +29,9 @@ window.initAjaxForm = function() {
var formURL = formObj.attr('action');
var formData = new FormData(this);

formData.append($(this).find('button[type="submit"]').attr('name'), $(this).find('button[type="submit"]').attr('value'));
var trigger = $(this).find('button[clicked="true"]');

formData.append($(trigger).attr('name'), $(trigger).attr('value'));

$.ajax({

Expand All @@ -40,6 +51,8 @@ window.initAjaxForm = function() {

$(ajaxForm).find('.ajax-content').replaceWith(data);

initButtonClickHandler();

if ($(ajaxForm).find('.g-recaptcha').length) {
var captcha = $(ajaxForm).find('.g-recaptcha');
var sitekey = captcha.data('sitekey');
Expand All @@ -56,6 +69,8 @@ window.initAjaxForm = function() {

$(ajaxForm).load(formAjaxUrl + ' .ajax-content', function () {

initButtonClickHandler();

$(this).css("min-height", $(this).css("height"));

if ($(this).find('.g-recaptcha').length) {
Expand Down
4 changes: 2 additions & 2 deletions Resources/Public/JavaScript/main.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
"typo3/neos": "~2.3.0",
"typo3/neos-nodetypes": "~2.3.0"
},
"suggest": {
"obisconcept/neos-bootstrap": "Provides jQuery which is required by the plugin",
"obisconcept/neos-jquery": "Add this package, if you don't use obisconcept/neos-bootstrap package or if you don't inluded jQuery by yourself"
},
"autoload": {
"psr-0": {
"ObisConcept\\NeosAjaxForm": "Classes"
Expand Down

0 comments on commit 35282f8

Please sign in to comment.