N
N
Nikita Nazarov2015-05-28 22:01:10
JavaScript
Nikita Nazarov, 2015-05-28 22:01:10

How to return JS processing to components that were dynamically loaded from a template?

There is a page with the materializecss.com library connected , there is a template in the tag <script type="text/template">containing a component from the materialize library. When dynamically adding a template using backbonejs to the html code, all event listeners of this component fly off. What is the best way to make friends with event listeners of the materialize library with the dynamic addition of the components of this library?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Golubev, 2015-06-04
@Noz01

If you are using jQuery to connect listeners, you need the .on() method - jquery.page2page.ru/index.php5/On
main problem with listeners is that they can only be attached to existing objects. To work around this problem, the listener is actually hung up on the existing object, but keeps track of the children. For example, you have a table in which fields are dynamically loaded. The table always exists. Here on it the listener for fields also is hung up.
More or less like this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question