Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem to load twice same wizard #18

Open
2 tasks
jonitopsg opened this issue Jan 31, 2019 · 1 comment
Open
2 tasks

Problem to load twice same wizard #18

jonitopsg opened this issue Jan 31, 2019 · 1 comment

Comments

@jonitopsg
Copy link

Checklist

  • I'm using version 0.8.1
  • My browser is: Chrome

Description

Hello, I have multiples forms wizard into popup and calling via javascript.
When I call the first popup, everything works very well.
When I call the first popup, close the popup and call again the same popup, the wizard not works.

This is my code in javascript to call the wizard.
$("#modalCMILivroRegisto_"+id).wizard('destroy');
$('#modalCMILivroRegisto_'+id+' .modal-dialog').html('');
$.ajax({
url: "/gestao/call/cmi/modal", // Url to which the request is send
type: "GET", // Type of request to be send, called as method
data: {id:id},
success: function(data) // A function to be called if request succeeds
{
$('#modalCMILivroRegisto_'+id+' .modal-dialog').html(data);
$('#modalCMILivroRegisto_'+id+' .modal-content#proprietario').select2({dropdownAutoWidth : true,width: 'auto'});
$(".data_inicio").datepicker({autoclose:true});
var elems = Array.prototype.slice.call(document.querySelectorAll('.js-switch'));
elems.forEach(function(html) {
var switchery = new Switchery(html,{ color: 'rgb(30, 136, 229)'});
});
$(".inputmask_cmi").inputmask();
$('#modalCMILivroRegisto_'+id).modal("show");
validateCMI(id);
}
});

function validateCMI(id){
var defaults = $.components.getDefaults("wizard");
var options = $.extend(true, {}, defaults, {
onInit: function() {
$('#contratoFormUpdateCMI_'+id).formValidation({
framework: 'bootstrap',
fields: {
name: {
validators: {
notEmpty: {
message: 'Este campo é obrigatório!'
}
}
},
meses: {
validators: {
notEmpty: {
message: 'Este campo é obrigatório!'
}
}
},
inicio_contrato: {
validators: {
notEmpty: {
message: 'Este campo é obrigatório!'
}
}
},
cliente_id: {
validators: {
notEmpty: {
message: 'Este campo é obrigatório!'
}
}
}
}
});
},
validator: function() {
var fv = $('#contratoFormUpdateCMI_'+id).data('formValidation');
var $this = $(this);

        // Validate the container
        fv.validateContainer($this);
        var isValidStep = fv.isValidContainer($this);
        if (isValidStep === false || isValidStep === null) {
            return false;
        }
        return true;
    },
    onFinish: function() {
        //$('#contratoFormUpdateCMI').submit();
        $('#contratoFormUpdateCMI_'+id).formValidation('defaultSubmit');
    },
    buttonsAppendTo: '.modal-body'
});
$("#modalCMILivroRegisto_"+id).wizard(options);

$('#inicio_contratoUpdateCMI_'+id).datepicker({
    format: 'dd/mm/yyyy'
}).on('changeDate', function(e) {
    $('#contratoFormUpdateCMI_'+id).formValidation('revalidateField', 'inicio_contrato');
});

$('#inicio_contratoUpdateCMI_'+id).datepicker({
    format: 'dd/mm/yyyy'
}).on('changeDate', function(e) {
    $('#contratoFormUpdateCMI_'+id).formValidation('revalidateField', 'inicio_contrato');
});

}

The wizard can't be called twice or more. Only works the first time.

How can i fixed this to call everytime I need to call any popup?

@matthew-hodgins
Copy link

matthew-hodgins commented Jun 1, 2020

It looks like you can call reset instead of destroy to achieve the desired results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants