Skip to content

Problem to load twice same wizard #18

@jonitopsg

Description

@jonitopsg

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions