2

I run an Ember app that runs inside a page that also loads Mootools.

It's an old app I am updating. With 1.0-pre4 it worked fine. With 1.0-RC8 (oldest found) till 1.5beta, no version works any more.

I tracked it down to this code included at the start of the Mootools code:

Function.prototype.extend = function(key, value) { /* ... */ }

Removing that line in mootools makes it work fine. Anyone else had a similar situation? Is there any way I can use those 2 libraries in the same page? (p.s. no, I cannot remove Mootools - cannot control it)

Flavio Copes
  • 4,131
  • 4
  • 27
  • 30

1 Answers1

1

Ember and Mootools extend the prototypes of the built in objects, the implementation of the function is different for them and this causes the issue.

Try turning off the prototype extensions in ember:

http://emberjs.com/guides/configuring-ember/disabling-prototype-extensions/

If this doesn't help then I believe you should get rid of the extend method in the Function's prototype.

The best solution would be to replace mootools with jQuery, but you'd need to have more access and time to do it.

Emil A.
  • 3,387
  • 4
  • 29
  • 46
  • thanks, I already tried it but unfortunately that does not help. – Flavio Copes Feb 24 '14 at 09:18
  • Using this workaround http://stackoverflow.com/a/4130778/205039 I managed to make it work. I wonder if there's a less 'hacky' solution – Flavio Copes Feb 24 '14 at 09:31
  • I don't think there's an easy solution to it if you can't control the mootools file. You could try this approach too, but it seems even more hacky: http://stackoverflow.com/questions/13990187/create-a-reset-of-javascript-array-prototype-when-array-prototype-has-been-modif – Emil A. Feb 24 '14 at 10:06