I have a table
I have constructed these rows and action buttons dynamically as soon as user clicked on Devices accordion.
When the user clicks on the (I)
<a href="" class="stats-modify-btn" title="Device Info" ng-hide="editDevice.num == $index" ng-click="device.viewEnabled = !device.viewEnabled; device.settingsEnabled = null; expandCollapseCurrent(device);"> <i class="fa fa-info ml15"></i> </a>
It should called expandCollapseCurrent()
function. Somehow it never reaches there, and there is nothing in the console for me to understand why it didn’t reach
$scope.expandCollapseCurrent = function(currentDevice) {
console.log('%c currentDevice = ' + currentDevice, "color: green;");
angular.forEach($scope.private_devices, function(device) {
if(device.name != currentDevice.name) {
device.settingsEnabled = false;
device.viewEnabled = false;
}
$scope.buttonShow.bandwidth = false;
$scope.buttonShow.acl = false;
});
}
It never did.
This is my entire code for that.
$('#wifi-devices-nav').click( function() {
if($('#wifi-devices-nav').hasClass('callout-expanded')) {
$.ajax({
method: 'GET',
url: '/api/telenet/' + '{{ $cpe_mac }}' + '/privateDevices',
crossDomain: true,
contentType: false,
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('value'),
"Accept": "application/json",
"Content-Type": "application/x-www-form-urlencoded",
"Cache-Control": "no-cache"
},
success: function(response){
$('.lds-ripple').fadeOut();
console.log(response.length);
for (i = 0; i < response.length; i++) {
var device = response[i];
if(device.up) {
console.log(device);
}
if(device.device_activity != "OFFLINE" && device.device_activity_v6 != "OFFLINE" ) {
console.log(response[i]);
if(device.up) {
var uplink = device.up.value + ' ' + device.up.suffix;
}
if(device.down) {
var downlink = device.down.value + ' ' + device.up.suffix;
}
if(device.device_activity == 'ACTIVE') {
var deviceStatus = 'green';
}else {
var deviceStatus = 'orange';
}
let row = `
<tr id="tr-${device.device_mac}">
<td>
{{-- Status --}}
<i class="device-status-circle fa fa-circle ${deviceStatus}" style="margin-left:7px; ">
</i>
${device.device_mac}
</td>
<td class="text-center">${device.ip_address_v6}</td>
<td class="text-center">${device.last_active} </td>
<td class="text-center">
<!-- View -->
<a href="" class="stats-modify-btn" title="Device Info" ng-hide="editDevice.num == $index" ng-click="device.viewEnabled = !device.viewEnabled; device.settingsEnabled = null; expandCollapseCurrent(device);"> <i class="fa fa-info ml15"></i> </a>
<!-- Edit -->
<a href="" class="stats-modify-btn" title="Edit" ng-hide="editDevice.num == $index" ng-click="editDevice.num = $index; hideAllBoxes()"> <i class="fa fa-pencil ml15"></i> </a>
<!-- Settings -->
<a href="" class="stats-modify-btn" title="Settings" ng-hide="editDevice.num == $index" ng-click="device.settingsEnabled = !device.settingsEnabled; device.viewEnabled = null; expandCollapseCurrent(device);"> <i class="fa fa-cog ml15"></i> </a>
</td>
</tr>
`;
$('#tablePrivateDevices').prepend(row).fadeIn('slow');
}
}
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(JSON.stringify(jqXHR));
console.log("AJAX error: " + textStatus + ' : ' + errorThrown);
}
});
}
});
Updated Observations
Any of the 3 buttons that I clicked, will refresh the page.
I have NO idea why it does that ...
Any hints/suggestions will mean a lot to me.