Iframe-resizer: Use iframeResizer after require.js

Created on 14 Jul 2016  Â·  4Comments  Â·  Source: davidjbradshaw/iframe-resizer

I am running into a problem when I use iframe-resizer on a page that uses require.js. I described the problem on StackOverflow.

The problem seems to be that the define call in iframeResizer.js lacks a name. See here:

It works reliably in my setup when I change the call to this:

define('iFrameResize',[],factory);

Most helpful comment

So ... I found a solution for my problem. I will not load iframeResizer myself with a script tag but will require it with require.js if it is available. And to make it work I have to use a custom config like so:

var myconf = require.config({
  context: 'mycontext',
  baseUrl: 'https://mydomain.com/js/'
});
myconf(['iframeResizer'], function (f) {
    f({}, 'myiframe');
});

Which needs iframeResizer.js to be placed in the js folder on the server.

All 4 comments

Can you make a PR and I will take a look when back from holiday.

On Thursday, 14 July 2016, Thomas Bilk Ù† [email protected] wrote:

I am running into a problem when I use iframe-resizer on a page that uses
require.js. I described the problem on StackOverflow
http://stackoverflow.com/questions/38377014/use-iframeresizer-after-require-js.

The problem seems to be that the define call in iframeResizer.js
https://github.com/davidjbradshaw/iframe-resizer/blob/master/src/iframeResizer.js#L995
lacks a name. See here:

It works reliably in my setup when I change the call to this:

define('iFrameResize',[],factory);

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/davidjbradshaw/iframe-resizer/issues/385, or mute
the thread
https://github.com/notifications/unsubscribe/AAkHEuQollDdjA7k5fN8nzWmoSvJeuuBks5qVlLTgaJpZM4JMina
.

Sent from my iPhone.

I looked into it but when I changed the define call and ran the tests about half of them failed. I guess this will not be the solution. It seems like the named module definition is a special case that was added for jQuery.

I will further investigate and update this issue.

So ... I found a solution for my problem. I will not load iframeResizer myself with a script tag but will require it with require.js if it is available. And to make it work I have to use a custom config like so:

var myconf = require.config({
  context: 'mycontext',
  baseUrl: 'https://mydomain.com/js/'
});
myconf(['iframeResizer'], function (f) {
    f({}, 'myiframe');
});

Which needs iframeResizer.js to be placed in the js folder on the server.

Oh I understand the issue now and yes that seems the best solution

Was this page helpful?
0 / 5 - 0 ratings

Related issues

snarfed picture snarfed  Â·  5Comments

todesignandconquer picture todesignandconquer  Â·  9Comments

russellballestrini picture russellballestrini  Â·  4Comments

mcodev1 picture mcodev1  Â·  9Comments

anlambert picture anlambert  Â·  6Comments