Skip to content

Commit

Permalink
Merge pull request #523 from paulandrieux/improvement/keep-active-tab…
Browse files Browse the repository at this point in the history
…s-on-novalidate

avoid tab change when a form is submitted with novalidate by remember…
  • Loading branch information
paulandrieux committed Jul 20, 2016
2 parents 0b2e6bd + b74bba1 commit 6e39d04
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Bundle/FormBundle/Resources/public/js/form.js
Expand Up @@ -12,6 +12,7 @@
**/

$vic(document).on('change', 'select[data-refreshOnChange="true"], input:checkbox[data-refreshOnChange="true"]', function(event) {
var input = $vic(this);
var form = $vic(this).parents('form');
loading(true);

Expand All @@ -34,11 +35,19 @@ $vic(document).on('change', 'select[data-refreshOnChange="true"], input:checkbox
data: form.serialize(),
async: true
}).done(function(response){

var actives = [];
$vic(input).parents('.vic-active').each(function() {
if ($vic(this).attr('id')) {
actives.push($vic(this).attr('id'));
}
});
//By default, the updateStrategy is html (a simple replace) but you can set your own function
//for example, append, after etc or even a custom one.
eval('$target.' + updateStrategy + '(response.html)');
var scripts = $target.find("script");

$vic(actives).each(function() {
$vic('a[href="#'+this+'"]').victab('show');
});
loading(false);
}).fail(function(response) {
console.log(response);
Expand Down

0 comments on commit 6e39d04

Please sign in to comment.