tags:

views:

277

answers:

3

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);
    }
+1  A: 

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

What is it exactly you are trying to do?

calumbrodie
`change` is for form values, `propertychange` is for changes in a property of a DOM element. Fundamentally different things.
Pekka
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
change is not the equivalent with propertychange
Elaine
+3  A: 

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
+1 cool info .. did not even know this event existed.. thanks for the heads up
Gaby
A: 

What about google Chrome or Safari? any solution for these two will be really appreciated.

Achilles
in effect, jQuery onChange() can fulfill propertychange event across browsers
Elaine
well maybe I should have written more. I want an event get triggered when an attribute of an element changes. As an example consider jQuery.accordion()this method statically sets the height of the container divs to a value and if you trigger anything that makes the content of that div, exceed that value, since the overflow is hidden and the div won't get higher, you wont see the bottom of the content.I want to do a $('div selector').css('hieght','') whenever the accordion sets the div's height value.onchange only works on "value"...
Achilles
onPropertyChange and DOMAttrModified work only in IE and FirefoxIs there any solution, except a timer, for WebKit browsers like Chrome and Safari?-----------That's what I wanted to ask!
Achilles
then the resolution noted in the topic edit section would be okayif ($.browser.msie) { $this.unbind("propertychange").bind("propertychange", function(e) { e.preventDefault(); bindTrigger(); }); } else { document.getElementById(_acBoxCtrlID).addEventListener("input", bindTrigger, false); }
Elaine