views:

1363

answers:

7

I have a table of paged data, along with a dynamically created pager (server-side AJAX call, apply returned HTML to the innerHTML of a div). When I click next page on my pager, an AJAX call is sent to the server to retrieve the next set of data, which is returned as a string of HTML. I parse the HTML and render the new table rows. I also retrieve the pager HTML and load it into its parent DIV innerHTML. No problems so far.

In Firefox I can click on the pager and all my javascript functions will execute normally. In IE, my first click will now not register, but the second click will perform the expected action.

What is it about IE that disables the first click on my returned HTML?

+1  A: 

I'm not sure if your issue is related to one I ran into with postbacks, but some of the AJAX libraries I was using was inserting extra controls into the page and was causing the generated ID in my link to no longer match up to the ID the server expected for the postback event.

The event was firing, but when the event was hooked up the ID's didn't match between the clicked link and the link object the listener was expecting.

However, after the first click the postback would cause the ID's to resynchronize and the second click would then be able to match up the IDs.

The way I discovered this was by examining the ID in the link before and after the first click.

Again, I'm not certain this is what is happening to you. The symptom is similar, but in my case both Firefox and IE were failing. Hopefully this is helpful.

Jay S
A: 

Do your pager hyperlinks have "#" as an href and are your JavaScript onclick event handlers returning false?

I've seen the problem before in IE whereby if you don't return false from the event handler then the first click will follow the hyperlink (back to the same page), but subsequent clicks will work because the page has already been visited.

John Topley
+1  A: 

Turns out I have a race condition. The library (coded in-house) is calling my callback function before I get a response from the server. As a result, none of my callback functions do anything, since I'm not passing a valid value. I've set a loop up to check every ten milliseconds for a value, otherwise wait. I modified the tutorial from here:

http://wonko.com/post/how-to-prevent-yui-get-race-conditions

Mike Robinson
A: 

If you've got a race condition, you may want to seriously rethink your methodology instead of setting a timer.

Is the paged-data a series of similarly-formatted items? you may want to consider stepping back to the DOM-level, cutting out your container's child elements and rebuilding them in the DOM. On my paginated scripts, I request a JSON string, which is then parsed by the requesting page. The result is an array of objects, which I can loop through and add to the container. It also helps reduce the likelihood of script-injection (innerHTML is notoriously dangerous when dealing with any sort of user-supplied content).

yaauie
A: 

sorry i did not post the code. here it is<li id="Servicii"><a href=# onclick="new Ajax.Updater('container', 'servicii.html');">Servicii</a></li>

thank you for the answers but can someone tell me how i can fix it?

A: 

Having the same issue. IE7 & IE8.

This works on all other browsers...but fails on IE7 & IE8. Help!

<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<script src="/javascripts/prototype.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<input type="button" value="Ajax Test" onclick="var myAjax = new Ajax.Updater('TestContent', '/store/home', {method: 'post', parameters: 'foo=bar'});" />
<div id="TestContent" style="margin: 100px; border: 1px solid #F00; height: 500px;">
</div>
</body>
</html>
A: 

Hi,

I have same issue with IE7. My event are inside one img onclick event inside the one a href. I have tested with href="#",emply or "return(false);" or without "a" but no issue for ie7 working fine ff. The problems is not here. In my case if the content updated is static (only returning one div with some content) the Update is working in IE, but if returning one dynamic content with full page html definition is no working. The request is here in all cases i can see the complete response(debugBar) but is not refreshing ie. I have tested with bustcaching but that is not the problem in all cases ie7 is not working with dynamics pages or pages with complete definitions html (header,body, form,..) only from staytics divs. Some guru can help us?.Regards