I have a dynamic selector. For example:
$ ("#listPlayerHome"). ('Click', '.classe joueurEngland', function () {// my work here}
... works properly. But if I like a dynamic Selector:
$ ("#listPlayerHome"). ('Click', '.classeJoueur' + teamHome, function ()
Where "Team" occurs in "England", it does not work at all.
This work But it will only happen once, when the .on
method is called. If you expect it to change It will not happen whenever you change the variable.
If you need to make it dynamic, you should rebound whenever you have to change the variable value.
Assume that you want it to bind the current value, and forgot the previous value, you can do this:
In this way, wherever you usually change the teamHome
value, you will use it instead:
// teamHome = "England"; AttachHandler ("England");
If at some point it does not do as you wish, and it does not really work. So this is because you are doing something wrong. In this case you will have to provide a complete set of code that can repeat the problem.
Comments
Post a Comment