views:

40

answers:

1

I want to disable inputs with a particular class, however I want to do this for any future inputs added to the page.

live() and delegate() can bind to events on elements that don't exist yet. Is there some sort of selector that can run some code on future elements in the same way?

+1  A: 

You could try to build your own custom event and bind it to your document. So every time you create an input you cann call your event. With your own event you are free to add the disabled attribute to all elements with your specific class.

With custom jQuery event you can add extremly complex behaviors to your document.

gearsdigital
Thanks for the answer but this means that instead of being able to listen for the addition of an input with a class X, I have to listen for events which might add an input with a class X. I was hoping for the simpler option but it looks like there's no document event fired when new elements get added
Chris Simpson
You are right... and also there is no event the browser fires when new elements where added to the document. Here is an overview about jQuery events: http://api.jquery.com/category/events/
gearsdigital