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);
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:
- Common Errors http://requirejs.org/docs/errors.html#mismatch
- Module with Name http://requirejs.org/docs/api.html#modulename
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
Most helpful comment
So ... I found a solution for my problem. I will not load
iframeResizermyself with ascripttag but will require it withrequire.jsif it is available. And to make it work I have to use a custom config like so:Which needs
iframeResizer.jsto be placed in thejsfolder on the server.