0

friends I have wrote my javascript on register page and edit page but on my edit page I found two errors. in magento 1.8. I added noconflict in layout/page.xml but i did not get any solution.

TypeError: element.attachEvent is not a function
http://localhost/cdd_chile/js/prototype/prototype.js
Line 5653

TypeError: element.dispatchEvent is not a function
http://localhost/cdd_chile/js/prototype/prototype.js
Line 5734

I am using these script on both page.....

<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);?>cddjs/jquery.Rut.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />

2 Answers2

1

use jquery's noConflict() like

$.noConflict();

Ex.

<script type="text/javascript" src"jquery-1.11.js"></script>
    <script type="text/javascript"> 
        $j = jQuery.noConflict(true); 
 </script> 

$j is now new alias to access jquery. It has overwritten you $ alias. You include noConflict right after you include jQuery or other plugin where you want to resolve conflict. If you want more explanation please see here

EDIT: Sample Example

<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
  <script type="text/javascript"> 
        $j = jQuery.noConflict(true); 

        $j(document).ready(function(e){     
            $j("#test").click(function(){
                 alert("hi");
            });
        });
 </script> 

</head>
<body>
<button id="test" type="button">Say Hi</button>
</body>
</html>
Community
  • 1
  • 1
Akki619
  • 2,386
  • 6
  • 26
  • 56
0

You can use:

var jQuery = $.noConflict();

Where jQuery will be alias to your jQuery library.

$.noConflict() will reslove any conflicts that may arise when you have '$' in any other libraries.

Varun
  • 597
  • 7
  • 26
  • new error created TypeError: $.validator is undefined http://localhost/cdd_chile/index.php/customer/account/ Line 389 – Amit Kushwaha Aug 27 '15 at 12:38
  • Are you loading the dependency in order. I mean first jQuery > jQuery UI > etc.. in your – Varun Aug 27 '15 at 12:43