Reputation: 23
I have a site based on SocialEngine 4 which uses moo-tools-1.2.5. There's an iframe with some js that opens in pop-up (with built-in Smoothbox plug-in). And I can't get a DOM element of this iframe from JS included into it just by calling $$(), I've needed to use a kludge like this:
var context = (window.frames[0]) ? window.frames[0] : window;
context.$('user_email').set('value', context.$('1_1_30').get('value'));
That's strange and I guess that it is unexpected behavior because JS in standard SocialEngine modules don't work within iframes too.
Upvotes: 2
Views: 1240
Reputation: 26165
this is because in 1.2.5, $$
is an alias for this.document.getElements
.
I suggest you use the IFrame wrapper class from mootools-core which can extend iframes so they get mootoolsy, you can then do stuff like:
var context = this.document, // window
iframe = document.getElement("iframe")
// if iframe found, change context to its contentDocument
iframe && (context = new IFrame("foo").contentDocument)
// wrapper.
!function() {
console.log(this.getElements("div"))
}.call(context)
Upvotes: 1