Reputation: 13800
I have this jQuery in a Magento install:
jQuery(document).ready(function($) {
"use strict";
var firstItems = $('.item.first');
// Find tallest .item per row; match rest of row to it
firstItems.each(function($) {
var $first, row, headings, heights, maxHeight;
$first = $(this);
row = $first.add($first.nextUntil(firstItems));
headings = row.find("h2, h5");
heights = headings.map(function($) {
return $(this).outerHeight();
});
maxHeight = Math.max.apply(null, heights);
headings.css("height", maxHeight);
});
});
Sadly, it's conflicting with Prototype. It is throwing the error:
[object object] is not a valid argument for 'Function.prototype.apply'
This leads me to believe that the conflict is coming from line 15:
maxHeight = Math.max.apply(null, heights);
Is there any way that I can wrap that function differently so that it's ignored by prototype?
Upvotes: 3
Views: 1126
Reputation: 6251
You can try :
jQuery(function($){
code_with_$;
});
and
(function($){
code_with_$;
})(jQuery);
also you required to declare jQuery above prototype. (You can use page.xml to define position of jQuery above prototype.)Then use your jQuery code using above mentioned structure it will resolve your problem.
Upvotes: 0