Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jQuery 1.6.1 "undefined" errors #40

Closed
dpie opened this issue May 23, 2011 · 5 comments
Closed

jQuery 1.6.1 "undefined" errors #40

dpie opened this issue May 23, 2011 · 5 comments

Comments

@dpie
Copy link

dpie commented May 23, 2011

jQuery 1.6.1 is throwing "undefined" errors when the parent element of itemSelector is missing either an ID or class. The following example uses just an ID on the parent element, and throws an "$(element).attr("class") is undefined" error. A similar error is thrown if you use just a class.

This example previously worked fine on jQuery 1.4.4. The error is being caused due to the way jQuery 1.6.x is reporting errors in the .attr() method. "As of jQuery 1.6, the .attr() method returns undefined for attributes that have not been set." http://api.jquery.it/attr/

The way to fix the issue (in the user's code) is to ensure the parent element has both an ID and class assigned to it. I figured this was worth reporting, in case a catch can be added into the InfiniteScroll JS code.

JavaScript:

$('ul#thumbnails').infinitescroll({
  navSelector  : "#results_nav",
  nextSelector : "#results_nav a.next_page",
  itemSelector : "ul#thumbnails li.thumbnail"
});

Failing HTML:

<ul id="thumbnails">...</ul>

Working HTML (the actual values of ID and class are not important, just that they are both present):

<ul id="thumbnails" class="infinite_scrollable">...</ul>

Hope this helps.

@paulirish
Copy link
Contributor

can you link to a page where we can reproduce this?

thx

@dpie
Copy link
Author

dpie commented May 23, 2011

The app using it is internal, so I can't. Sorry.

@lukeshumard
Copy link
Contributor

can you let us know what line of code this is happening on?

@lukeshumard
Copy link
Contributor

bueller?

@dpie
Copy link
Author

dpie commented Jun 7, 2011

This bug was appearing under Infinite Scroll 2.0b1.110420 on line 81:

var number = $(element).length + $(element).html().length + $(element).attr("class").length + $(element).attr("id").length; 

It looks like it has since been resolved in the recent 2.0b2.110603 update.

@dpie dpie closed this as completed Jun 7, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants