D
D
Dmitry Baskakov2021-07-15 07:28:50
JavaScript
Dmitry Baskakov, 2021-07-15 07:28:50

How to track the change of the textarea, which is changed by js, not by the user?

There is a code:

$($('.modal-dialog'))
    .find('[name="id"]')
    .change(function (){
        console.log('oke')
        renderModalCompanies()
    })


The desired selector is found (checked), but change does not work on it
The selector itself looks like this and its value changes: How can I connect changes in the input and the change event? It seemed to me that everything is solved by simply hanging an event, and for inputs, even changed via JS, everything works. But apparently I'm wrong. And if so, please tell me why it's wrong.
<input type="hidden" name="id" id="id" value="">


Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Sokolov, 2021-07-15
@sergiks

Events will only be triggered by user actions through the UI. When changing the value of value from the code, the events do not fire.
1. You can reassign the property valueof the desired input, and artificially create an event in the setter when the value changes. Code and idea from here .
2. When changing the value, in the same section of code, you can also create an event on the element.

M
Mikhail Osher, 2021-07-15
@miraage

event.isTrusted

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question