Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder patryk's Avatar
    Join Date
    Oct 2012
    Location
    /dev/couch
    Posts
    398
    Thanks
    2
    Thanked 64 Times in 64 Posts

    change event isseue

    hey
    i have a slight problem sith my script
    i need to assign onchange handler to all inputs on a page. i used this (jQery):
    Code:
    $('input').change(function() {
    	alert('test');
    });
    the problem is that i need this to be trigerred not only by changes done from keyboard, but by changes done by other scripts as well.
    is there some simple way to do that?
    i know i can trigger change event from each other script, but is there some simpler method?

    -------------------------------------------------------------------------------
    "Real Programmers can write assembly code in any language" - Larry Wall

  • #2
    Regular Coder patryk's Avatar
    Join Date
    Oct 2012
    Location
    /dev/couch
    Posts
    398
    Thanks
    2
    Thanked 64 Times in 64 Posts
    update:
    i wrote a workaround using setInterval()
    selector is by class to expand it to other form fields.
    Code:
    	$('.monitored').each(function() {
    		$(this).data('oldVal', $(this).val());
    	});
    	setInterval(function(){
    		$('.monitored').each(function(){
    			if($(this).data('oldVal') != $(this).val()){
    				$(this).data('oldVal', $(this).val());
    				//do stuff here
    				console.log('change');
    			}
    		});
    	}, 100);
    but this aproach does seam kinda unelegant... how would you guys do this?

    -------------------------------------------------------------------------------
    "Real Programmers can write assembly code in any language" - Larry Wall


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •