meetselva / attrchange

onattrchange listener
GNU General Public License v3.0
207 stars 57 forks source link

Native prototype version of attrchange #3

Closed pat-richter closed 11 years ago

pat-richter commented 11 years ago

Hi,

maybe you know advertising, that fills the body's background with a custom color. I want to prevent this and attrchange seems to be awesome! The problem is, that it's not available before the document is loaded. But the background is filled with a color before.

Is it possible to build a prototype version or anything, that does not require jQuery, so I can use attrchange earlier?

Element.prototype.meetselva_attrchange = function( callback ) {
    ...
}

Then I could use it without jQuery on the body element.

I know the downsides of prototyping, but don't have any other idea therefore. I'm interested in work with you but I don't get it alone.

Kind regards, Patrick

meetselva commented 11 years ago

Hello Patrick,

I don't think document.ready is your problem. The body tag should be available only after its declaration. See this demo below http://jsbin.com/uqenef/1/edit which shows that attrchange doesn't wait until document ready. You can bind attrchange to any element that is available when it is called.

If my understanding is incorrect, drop me a test case using http://jsfiddle.net or http://jsbin.com where I can look at?

Regards, SK

pat-richter commented 11 years ago

Hello again,

wow, I did never even thougt about using jQuery without <$(document).ready()>. I've read some posts now and have to thank you for this learning. So, a prototype version is not needed. Thank you.

Unfortunately the advertiser does a double check, if the background is inked with the correct color. So it results in an infinite loop.

Thank you very much for the support and the learning.

Kind regards, Patrick