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

302
Views
Angular 2 (click) and jQuery .clone() method not working

So i have a template for Angular 2 and this template uses jQuery components that "works". Well.. When the page is resized this fire a jQuery function that re-design the sidebar adding all the items of the top navbar using the "clone()" method of jQuery. Something like this:

... code ommited ...
 $navbar = $('nav').find('.navbar-collapse').first().clone(true);
... more code ommited...

This works well, this clone all the items of the navbar on the sidebar. The only problem is a button that i have on the sidebar to logout the system. This is the code:

<a class="text-danger link-pointer" (click)="doLogout()">
    <i class="pe-7s-power"></i> Cerrar Sesión
</a>  

As you can see, i use the (click) binding that call a method of my class. The problem is: When the jQuery clone occours then is cloned, but without the binding. So the link is broken. I can't use the [routerlink] binding because i need execute some code before redirect the user to the logout page.

Any idea to do this? Thanks a lot.

about 4 years ago · Santiago Trujillo
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!