Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

259
Views
Quiero eliminar elementos de la base de datos de firebase usando javascript al hacer clic en el botón

Puedes ver la imagen que elemento quiero eliminar ingrese la descripción de la imagen aquí

ingrese la descripción de la imagen aquí

El código de búsqueda se da a continuación

 var dbImages = firebase.database().ref("images"); dbImages.on("value", function(images){ if(images.exists()){ var categorieshtml = ""; images.forEach(function(image){ console.log(image.val().title); categorieshtml += "<tr>"; //for category name categorieshtml += "<td>"; categorieshtml += image.key; categorieshtml += "</td>"; //for category description categorieshtml += "<td>"; categorieshtml += image.val().title; categorieshtml += "</td>"; categorieshtml += "<td>"; categorieshtml += image.val().desc; categorieshtml += "</td>"; //for category thumbnail categorieshtml += "<td> <img width='250' height='150' src='"; categorieshtml += image.val().url; categorieshtml += "' /></td>"; categorieshtml += "<td>"; categorieshtml += "<button id='btn-delete' onclick='delete_row("+image.key+")'>Remove</button>" categorieshtml += "</td>"; categorieshtml += "</tr>"; }); $("#images").html(categorieshtml); } }); function delete_row(childKey) { firebase.database().ref().child('images/' + childKey + '/').remove(); alert('row was removed'); reload_page(); }

Quiero eliminar el nodo que figura en la imagen usando el botón. Puedo obtener fácilmente el valor, pero el botón Eliminar no funciona, por favor, ayuda. Quiero eliminar el elemento de la base de datos en tiempo real de Firebase haciendo clic en el botón en JavaScript.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Te faltan comillas alrededor del argumento en la llamada a delete_row aquí:

 categorieshtml += "<button id='btn-delete' onclick='delete_row("+image.key+")'>Remove</button>"

Si revisa el HTML generado, verá que se ve así:

 delete_row(-N2j...JIWFH)

El argumento aquí se interpreta como un token/variable, en lugar de un valor de cadena literal.

Para solucionar esto, agregue otro par de comillas en su código:

 categorieshtml += "<button id='btn-delete' onclick='delete_row(\'"+image.key+"\')'>Remove</button>"
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!