Conflict with prototype

2

I have a question that is ending my nights .... I use the magento version 1.9 .... more when I installed the ecomdev module to do the freight calculation on the product page it informs me an error clicking on calculate freight ...

Uncaught TypeError: undefined is not a function
 return elements.inject(initial, function(result, element) {
      if (!element.disabled && element.name) {
        key = element.name; value = $(element).getValue();
        if (value != null && element.type != 'file' && (element.type != 'submit' || (!submitted &&
            submit !== false && (!submit || key == submit) && (submitted = true)))) {
          result = accumulator(result, key, value);
        }
      }
      return result;
    });
  }
};

The error is reported in the key = element.name; value = $(element).getValue();

    
asked by anonymous 10.03.2015 / 18:57

1 answer

1

Prototype and jQuery use both the variable $ and are overlapping. I think in your case you're loading jQuery after the Prototype.

The solution is to put jQuery in non-conflict mode and use jQuery instead of $ .

I suggest in the head of the page you have:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
var $j = jQuery.noConflict();
</script>
<script src="https://ajax.googleapis.com/ajax/libs/prototype/1.7.2.0/prototype.js"></script>

In this way you free the dollar for the Prototype . If you continue to have errors you have to go over the code and change the dollars that are in jQuery code to $j(etc...) .

If you do not know how ... ask here. But you'll have to make the code available, or a link to the page.

    
10.03.2015 / 20:45