-3

I create a dialog with jquery/jquery ui. When in this dialog a inputfield is changed, then i need a reaction.

but when i use

$( document )
    .on( "change", function(){
    alert("it works");
} );

then i got the alert, but i got also the alert when i didnt have open the dialog and change anywhere in current page something.

jsFiddle

A. Wolff
  • 73,242
  • 9
  • 90
  • 149
Miracle Johnson
  • 701
  • 2
  • 13
  • 28

2 Answers2

2

Do this:

$(document).on("change",'someSelector' function(){
    alert("it works");
});

someSelector is the context

Amit Joki
  • 56,285
  • 7
  • 72
  • 91
0

You need to target the specific element of your dialog, not the "document".

$("#IDOFYOURINPUTFIELD").change(function(event){
    alert("it works");
} );
blue112
  • 46,589
  • 3
  • 43
  • 54