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

210
Views
El componente Vanilla Javascript no funciona dentro de otro componente

Hice un componente de barra de búsqueda en javascrip

 const template = document.createElement("template"); template.innerHTML = ` <div class="search"> <div className="searchIcon"> <img src="searchIcon.png" alt="search" width="13rem" /> </div> <input type="text" placeholder="Search" /> </div> `; class SearchBar extends HTMLElement { constructor() { super(); const el = this.attachShadow({ mode: "open" }); el.appendChild(template.content.cloneNode(true)); this.search = el.querySelector("input"); this.search.addEventListener("focus", () => { this.search.style.outline = "none"; }); } } customElements.define("search-bar", SearchBar);

y luego creé otro componente donde traté de insertar mi barra de búsqueda personalizada:

 const template = document.createElement("template"); template.innerHTML = ` <div class="navContainer"> <div class="titleContainer itemFlex"> <img src="arrow.png" alt="sageata" width="15rem" height="15rem" /> <h2 class="title">TITLURILE.RO</h2> </div> <div class="itemFlex searchContainer"> <search-bar></search-bar> </div> </div>`; class TopBar extends HTMLElement { constructor() { super(); const element = this.attachShadow({ mode: "open", }); element.appendChild(template.content.cloneNode(true)); } } customElements.define("top-bar", TopBar);

Mi pregunta es cómo hago para que los dos archivos js se comuniquen entre sí para mostrar mi componente de barra de búsqueda en la barra superior.

about 4 years ago · Juan Pablo Isaza
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!