javascript - How can I monitor the value of a hidden input element? -


itemprop = "text">

I have a selection element that, with a value, a hidden INPUT is clicked through javascript to each option ( Representing each selection with the footage) and I want to be able to monitor the changes for another javascript function. For modularity, I can not integrate the second function in the first function. I too would not like to choose the value of INPUT hidden to avoid hacks. Currently I'm using the onclick event on the device, which includes SELECT and hidden INPUT, but it is also quite hack-ish. Do you know a way to monitor a hidden input element for changes?

Then, you have:

  • Function A, which is hidden INPUT Updates
  • Function B, which should be called when INPUT is updated.

Why not make your own "event" that whenever it works, there is a call / dispatch?

I believe most JavaScript frameworks support the concept of custom events very easily, but this function is a series of calls.

For example, create some Object D, which represents Dispatcher for an Event. Yes it's silly, but I'm trying to keep this concept simple. This object D keeps a list of functions, which has "registered" for its event, and when the event is dispatched, it calls those tasks.

Something like this:

  var d = (function () {var funcs = []; function fire () {for (var i = 0; i & lt; Funcs.length; ++ i) {funcs [i] .call ();}} function register (newfunc) {funcs.push (newfunc);} return {fire: fire, register: register};}) ();  

You only have two things left - Function A: Arrange the fire:

  Function A () {// Input to update the INPUT D.fire (); }  

And also, onload , "Register" function B is called when the event is called:

  d .register (b);  

A and B do not know anything about each other, and only one-third know about the object, because this approach is different-type modules (or Whatsoever is said).


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -