Datatable using Bootstrap Toggle Switch

Datatable using Bootstrap Toggle Switch

genesisrgenesisr Posts: 15Questions: 6Answers: 0

Hello! I'm using this plugin http://www.bootstraptoggle.com/ inside datatable.

In a column I have this switch, so I want to open a modal when I clic on it, but the problem is it seems that is not recognizing the function I'm calling.

This is an example of what I'm saying:

I initialize my datatable and I have this code inside it:

        "fnDrawCallback": function() {
              $('.mySwitch').bootstrapToggle({
               on: 'Activo',
               off: 'Inactivo',
               onstyle: "success",
               offstyle:"danger" ,
               size:"mini"
           });

            },

rowCallback: function(row) {
if (!row.compiled) {
$compile(angular.element(row))($scope);
row.compiled = true;
}
},

columns: [

            ...
            {"data" : function(data) {

                return '<input type="checkbox"  ng-click="openModal();" id="switchActivar" class ="mySwitch" checked data-toggle="toggle">'

            }},

$scope.openModal = function(){
//alert("hey ");
$("#modalActivarDesactivar").modal("show");
}

It's like is not recognizing angular, but this only happens when I put this switch inside datatable, I tried putting the switch in anyway of the html and it works, but inside datatable does not. :/ What am I missing? I hope you could help me! thankss!

Answers

  • genesisrgenesisr Posts: 15Questions: 6Answers: 0

    I want to clic in this switch and open a modal, I found it but if I'm using the switch outside the datatable, but that's not what I want, I did it because I want to prove if it working (It works in that case), but when I clic on this switch (In the datatable) it doesn't work

  • genesisrgenesisr Posts: 15Questions: 6Answers: 0

This discussion has been closed.