Magento 2 JavaScript – How to Disable JQMigrate Logging
javascriptjquerymagento-2.1
We keep receiving this log and stack trace from JQMigrate, but it seems to just be a warning. Is there a way to just straight up disable logging in production?
Best Answer
I ended up overriding the core jquery-migrate in our theme so I could set the migrateMute option.
In my theme require-jsconfig.js I set this override:
This depends on the Magento version. For version CE 1.7 the piece of code you wrote is commented out. In 1.6 and lower it's not.
Knowing this, I assume it's safe to comment the code and not worry about future upgrades.
You will need to use spconfig object. Replace your catalog/product/view/type/options/configurable.phtml code with below. I have used the onchange="spConfig.getSelectedIndex()" onchange function.
<?php
$_product = $this->getProduct();
$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes());
?>
<?php if ($_product->isSaleable() && count($_attributes)): ?>
<dl>
<?php foreach ($_attributes as $_attribute): ?>
<dt><label class="required"><em>*</em><?php echo $_attribute->getLabel() ?></label></dt>
<dd<?php if ($_attribute->decoratedIsLast) { ?> class="last"<?php } ?>>
<div class="input-box">
<select name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>" class="required-entry super-attribute-select" onchange="spConfig.getSelectedIndex()">
<option><?php echo $this->__('Choose an Option...') ?></option>
</select>
</div>
</dd>
<?php endforeach; ?>
</dl>
<script type="text/javascript">
var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>);
spConfig.getSelectedIndex = function ()
{
for (var i = this.settings.length - 1; i >= 0; i--)
{
if (this.settings[i].selectedIndex == 0)
{
alert('yes');
}
}
}
Best Answer
I ended up overriding the core
jquery-migrate
in our theme so I could set themigrateMute
option.In my theme
require-jsconfig.js
I set this override:Then copied the code
jquery-migrate.js
file to the themejs
directory, and added this line towards the top: