Skip to main content

Bug Tracker

Side navigation

#208 closed enhancement (worksforme)

Opened September 20, 2006 10:40PM UTC

Closed October 13, 2006 12:48PM UTC

Last modified June 20, 2007 01:46AM UTC

$.load should automatically be JQuerified

Reported by: anonymous Owned by:
Priority: minor Milestone:
Component: ajax Version:
Keywords: Cc:
Blocked by: Blocking:

Would be nice if JQuery assumed you want to use it on HTML files loaded into elements using .load, instead of having to put everything into a function and then use that function in a callback. It can make code messy quick.

Attachments (0)
Change History (4)

Changed October 06, 2006 02:57PM UTC by joern comment:1

Could you explain this some more?

Changed October 11, 2006 09:26PM UTC by anonymous comment:2

Basically document.ready is the default callback for .load. If I put something like $(".hello").addClass("world"); in my document ready, and I load some content that uses the "hello" class it does not add the "world" class added to the content that was just loaded.

You can get around it by doing a myready function which contains all the stuff you want to do, and call that function from the load callback, and in document.ready, but it's rather non-intuitive.

Changed October 13, 2006 12:48PM UTC by joern comment:3

resolution: → worksforme
status: newclosed

Defining your DOM ready code inside a single function and passing that function to both $(document).ready and as a load() callback isn't what I'd call messy. On the other hand, automatically calling all events registered for document.ready when doing a load would result in quite unexpected behaviour.

Changed October 15, 2006 02:41AM UTC by john comment:4

I have to agree with Joern. Disregarding the fact that it would be really difficult to implement, having code be applied on .load() would definitely be unexpected, and possibly unwelcome.

For example:



What if I don't want the 'data' class being applied to my incoming ul element? Should I be forced to go through and remove everything that was added?

An optional implementation might be an interesting project to consider, some day. For that reason, I've added it to the HardProblems page.