Reputation: 10071
I have my code snippet like this...
$('#ShowRatings a.show').click(function() {
$('#contents').html('#some_div');
createGraph($('#contents .ratings-contents'));
});
My problem is that the click trigger ('#ShowRatings a.show'
) I am using does not change when the page loads, but the selector which is used in function createGraph()
is changing - I am manipulating the jquery dom. So, in IE6/IE7, it shows an error like object not found
. In other browsers this snippet works fine.
If it would have been an event trigger that would have been manipulated using jquery, I would have live
event, but how can I handle the selectors that are changing?
Upvotes: 1
Views: 267
Reputation: 2165
Do you have this code in $(document).ready(function(){ your code; });
?
If you use live
it should be ok.
Divs you want select are not changing (if you don't manipulate html code via javascript or jquery). In my opinion your code is before the html code, so it is triggered before DOM is loaded. In FF it could work, because it is so fast that DOM is created before click
is defined. Inside click
function it works always, because every time you call click
jQuery makes new search in DOM elements. So please use ready I mentioned.
edit:
Do:
$('#ShowRatings a.show').live('click',function() {
$('#contents').html('#some_div');
createGraph($('#contents .ratings-contents'));
});
Upvotes: 1