Hi!
I have an app using ionic 2 and Im trying to open a div when the user clicks on a button.
I have a list of cards that each one has an id. I’m using DOM to manipulate the view but this just works when I got internet connection, if a turned off the div that I clicked dont show up.
my code:
itemTapped(event, bloco) {
if(this.reading.block_unit === this.READING_BY_DIVISION) {
var id = bloco.id_division;
var classname= document.getElementById(id).className;
this.id_division = id;
if(classname == "hide") {
this.openDiv(id);
if(this.last != undefined && this.last != id) {
this.closeDiv(this.last);
}
} else {
this.closeDiv(id);
}
this.last = id;
} else {
this.nav.push(UnidadePage, {
portal: this.portal,
status_portal : this.status_portal,
division_id: bloco.id_division,
unidades: bloco.units,
division_name: bloco.name,
reading: this.reading
});
}
openDiv(id) {
this.value = "";
this.note = "";
this.base64Image = "";
if(this.network.isNetworkAvailable()){
this.readingService.getByDivision(id,this.reading.type).subscribe(
data => {
if (data.length > 0)
this.value = data[0].value;
},
err => {
console.log(err);
}
);
}
document.getElementById(id).className = "";
document.getElementById("camera-" + id).className = "";
document.getElementById("note-" + id).className = "";
}