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

Iframe called twice (Chrome) #48

Open
twistedvibe opened this issue Jan 30, 2014 · 4 comments
Open

Iframe called twice (Chrome) #48

twistedvibe opened this issue Jan 30, 2014 · 4 comments

Comments

@twistedvibe
Copy link

I've been using this for sometime and have had no issues up until now.

I have an iframe within the modal dialog (with a loader image behind it whilst it loads in).

The iframe page is called twice (I can tell this server side). It appears related to onOpen, if onOpen is removed the the iframe only gets called once.

Great dialog by the way - very impressive I've found it very useful. If this can be resolved I'll be happy to donate.

@twistedvibe
Copy link
Author

I use the following code to call simple modal:

templatemodaldialogopen

@twistedvibe
Copy link
Author

UPDATE: This appears to only affect Google Chrome!

@rollisoj
Copy link

I am having the same problem however it happens in IE as well as Chrome. I can get rid of the problem by commenting out the appendTo('body'); section in the jquery.simplemodal-1.4.4.js but then the modal is not centered correctly when it is shown.

        // add styling and attributes to the data
        // append to body to get correct dimensions, then move to wrap
        s.d.data = data
            .attr('id', data.attr('id') || s.o.dataId)
            .addClass('simplemodal-data')
            .css($.extend(s.o.dataCss, {
                    display: 'none'
            }))
            //.appendTo('body');
        data = null;

Any ideas on how to resolve this?

@alfasapy
Copy link

@rollisoj This is how I resolved it.
I am using simplemodal v1.4.5, tested in Chrome and IE10

Remove and save the original Src before the data is first appended to the body

var iframeElement = $(data.find('iframe')[0]);
var savedSrc = iframeElement.prop('src');
iframeElement.prop('src','about:blank');
s.d.data = data
...

Right before data is appended to the wrap element, you can bring back the Src

// Reinstate src
// IE10 will trigger a request on src prop update, remove from DOM
s.d.data.detach();
$(s.d.data.find('iframe')[0]).prop('src', savedSrc);
s.d.data.appendTo(s.d.wrap);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants