4

In jQuery, $.bind("propertychange", callback) is not available within Firefox, how can I solve this?

Thanks

eventually, I use this to fulfill:

if ($.browser.msie) {
        $this.unbind("propertychange").bind("propertychange", function(e) {
            e.preventDefault();
            bindTrigger();
        });
    }
    else {
        document.getElementById(_acBoxCtrlID).addEventListener("input", bindTrigger, false);
    }
Elaine
  • 1,288
  • 5
  • 17
  • 35
  • what is the `propertychange` ? `.bind()` works with events.. Check out the documentation at http://api.jquery.com/bind/ – Gabriele Petrioli Jun 07 '10 at 10:29
  • I doubt `$.bind("propertychange", callback)` is available in **any** browser – jAndy Jun 07 '10 at 10:30
  • 3
    @jAndy, @Gaby: [ `onpropertychange` ](http://msdn.microsoft.com/en-us/library/ms536956\(VS.85\).aspx) is a microsoft proprietary event, so the OP's code should work in IE. It's not supported by any other browser. – Andy E Jun 07 '10 at 10:36

3 Answers3

10

onpropertychange is a proprietary event implemented by Microsoft for Internet Explorer. It is not supported in other browsers.

The closest equivalent is DOMAttrModified, although this appears to only fire when attributes are modified (e.g., via .setAttribute("value", "string")) and not properties (e.g. .value = "string").

onchange is available for input elements, but will only fire when that element loses focus. Beyond that, your alternative is to use a resource-hungry timer to constantly check for a change.

Andy E
  • 338,112
  • 86
  • 474
  • 445
6

You have to use $(#inputEvent).bind("input", function(){ // your code });

Ave
  • 282
  • 2
  • 4
  • 9
  • The `input` event is a HTML5 event. I will not work in < IE9. http://stackoverflow.com/questions/6488171/catch-only-keypresses-that-change-input – rmoestl Apr 25 '13 at 05:56
1

Can't you just use .change()?
http://api.jquery.com/change/

What is it exactly you are trying to do?

calumbrodie
  • 4,722
  • 5
  • 35
  • 63
  • `change` is for form values, `propertychange` is for changes in a property of a DOM element. Fundamentally different things. – Pekka Jun 07 '10 at 10:41
  • I guessed that. In that case, cant you just have the callback fire at the same time as the function that is causing the property to change? I can't see when you would need to monitor a DOM element when you are in control of the javscript that would cause the DOM to be changed. – calumbrodie Jun 07 '10 at 15:43
  • change is not the equivalent with propertychange – Elaine Jun 11 '10 at 03:13