Y
Y
Yaroslav2015-11-06 12:26:59
JavaScript
Yaroslav, 2015-11-06 12:26:59

How to make the function work in dynamics?

Let's say there is a table and buttons for deleting, adding rows / columns. When 1 cell remains, hide the buttons.
The function has the condition "if 1 row - hide the button, 1 column - hide the button." The function then works correctly - but only for the initial state of the table. You can, of course, call the function in the buttons, but it seems to me that there is an easier option.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Denis Ineshin, 2015-11-06
@gonchaar

Every time you click delete row/add row you should fire a callback that will re-run your function that hides/shows the buttons.

Y
Yaroslav Lyzlov, 2015-11-06
@dixoNich

No. What do you mean "function worked in dynamics"? Is there any code that needs to be executed? Function code? Duck call the function when needed. There is no magic here.

M
Maxim Nepritimov, 2015-11-06
@nepritimov_m

It turns out that when you add new elements, events are not attached to them. Well, or in the function that hides / shows, the table is cached in its original state.
After adding a new element, it is necessary to call a function that will hang an event on a new element, or simply recheck all elements, taking into account those just added to the DOM, and hang a handler on all elements.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question