0

My issue is that after changing views using routing, the jquery components in my page doesn´t get rendered. I have customized ui components like dropdowns that are not being processed. I saw this answer: Angular.js App with routing.. Cannot get jquery ui layout plugin working on 2nd view

But I can´t figure out how to make it work in my case. It seems that when angular renders the template, any but angularjs code is processed.

Thanks so much in advance.

Code: http://plnkr.co/1mwMcsqMxWGTheoQmJ22

Community
  • 1
  • 1
Guillermo
  • 1,493
  • 3
  • 16
  • 35

1 Answers1

1

In the example you've provided, you're not actually loading the file with the jQuery code in it (jqcode.js).

The real problem however, as you can see in this version of your example, is that the document ready event is executed before your template has been loaded and rendered. This means that the element your jQuery code is attempting to target does't exist when you try to manipulate it.

You should really look into Angular directives which is where you are advised to place any DOM manipulation logic within an Angular project:

If you have to perform your own manual DOM manipulation, encapsulate the presentation logic in directives.

From the Angular documentation for controllers.

net.uk.sweet
  • 12,444
  • 2
  • 24
  • 42
  • Hey, thanks so much for your answer, I think that I've solved my issue and it's working now. Code attached. I'm using a directive with "M" restriction, to initialize a bunch of a stuff by executing the directive only once. (In the example it's just a text by in my app will be ten dropdowns..) Plunker: http://plnkr.co/5qZbyon9JbUy9pUmaAp6 – Guillermo Sep 20 '13 at 01:55