How can I make an AJAX link work once it is moved out of the iFrame?

Posted by KcYxA on Stack Overflow See other posts from Stack Overflow or by KcYxA
Published on 2010-05-30T19:54:48Z Indexed on 2010/05/31 0:22 UTC
Read the original article Hit count: 485

Filed under:
|

Hi,

I am using an iFrame with a form that return some content with an AJAX link.
I am then moving the returned content out of the iFrame into the main page.

However, then the ajax link does not work and the error "Element is null" is created once the link is clicked.

How can I move content from the iFrame and still have the AJAX link working?

Here's the code returned by the iFrame:

<span id="top">
    <a id="link8" onclick=" event.returnValue = false; return false;" href="/item_pictures/delete/7">
       <img src="/img/delete.bmp"/>
    </a>

    <script type="text/javascript">
        parent.Event.observe('link8', 'click', function(event) { 
           new Ajax.Updater('top','/item_pictures/delete/3', {
               asynchronous:true, evalScripts:true, 
               onCreate:function(request, xhr) {
                     document.getElementById("top").innerHTML = "<img src=\"/img/spinner_small.gif\">";
               }, 
               requestHeaders:['X-Update', 'top']
           }) 
        }, false);
    </script>

</span>

© Stack Overflow or respective owner

Related posts about AJAX

Related posts about iframe