Question

I am using Magento 1.7.2, jQuery 1.9.1 and Prototype.js 1.7, and Zurb Foundation 4 javascript plugins, namely the joyride plugin.

Well after installing the joyride plugin using the foundation.js and foundation.joyride.js files, I found that prototypejs creates a property Function.prototype.bind= function(){...}, and this is being called from foundation.js under a function called init_lib or lib_init (can't remember) that calls the bind method, probably the ecmascript5 version of bind.

When debugging the code, I saw it step into prototypejs bind from init_lib in foundation.

How can I fix this conflict without having to rename all prototypejs uses/calls of bind to some other name?

The $.foundation() method is called when the dom is ready so this is after prototypejs objects are initialized.

Thank you for any help.

Was it helpful?

Solution

PrototypeJS 1.7.1 handles Function.bind as a polyfill instead of assuming it does not exist.

In the latest version it will check if the bind() method is available on the Function prototype before it adds it (or replaces)

If you can't upgrade then find this block

return {
    argumentNames:       argumentNames,
    bind:                bind,
    bindAsEventListener: bindAsEventListener,
    curry:               curry,
    delay:               delay,
    defer:               defer,
    wrap:                wrap,
    methodize:           methodize
}

and replace the bind definition like this

     bind:                Function.prototype.bind ? Function.prototype.bind : bind,
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top