Open a modal bootstrap window with JavaScript [closed]

3

I have a function in JavaScript that validates data. The problem is that it uses alerts to warn when data is badly loaded. What I want to do is show Bootstrap modal windows to see the error.

This is what I did, which does not work:

var contador = <?=($_GET['sensores'])? count($_GET['sensores']):'0'?>;
    window.validar = function (cual){
        if(cual.value == -1){

        }
        if($("#muestragrafico1").is(':checked')){
            var cantidad = 3;
        }else{
            var cantidad = 1;
        }
        if(cual.checked){
            contador++;
        }else{
            contador--;
        }
        if(contador <= cantidad){
            return true;
        }else{
            if (cantidad == 3) {
                //alert("Solo puede seleccionar un máximo de "+cantidad+" sensores.");
                $('#myModalExito').modal('show');

            }

            if (cantidad == 1) {
                alert("Solo puede seleccionar un máximo de "+cantidad+" sensores.");
            }
            contador--;
            return false;
        }
    }
    
asked by sinaxtis 11.01.2017 в 16:05
source

1 answer

3

This is wrong and should give you an error:

mE.function.modal();

To open and close bootstrap modalities programmatically, it is done from the same API through jQuery:

$('#myModalExito').modal('show'); // abrir
$('#myModalExito').modal('hide'); // cerrar
    
answered by 11.01.2017 в 16:18