Mootools and jQuery conflict

I have a simple form on a page loading Mootools and JQuery. JQuery is not in conflict mode, which does not seem to be causing any problems.

There is a form element called "name" -

<input class="required" id="sendname" name="sendname" value="">

And I'm trying to attach a click event to it using Mootools to update something else when I click on the name:

$('sendname').addEvent('click', function(e){
    // do stuff.
});

The problem is that the click event is never added.


This error appears on boot:

Uncaught TypeError: Cannot call method 'addEvent' of null

When I try to interact with an item in the js console, I get the following error:

> $('sendname').setProperty('value', 'test');
TypeError: Object sendname has no method 'setProperty'</strike>

EDIT: The previous one was fixed by downloading newer Mootools. However, the click event still does not work correctly, although it does not cause errors or warnings.

, . , jQuery, , $ , , , noConflict . ?

+3
4

OP, jQuery/Mootools. JQuery noConflict . . Jsfiddle - http://jsfiddle.net/uSwzL/1/

0

... , .

id period , :

$('#sendname').addEvent('click', function(e){
    // do stuff.
});

# #sendname

+5

MooTools Dollar Safe, $ libs, MooTools .

, :

document.id('SomeElementID').someMethod()

, , , jQuery MooTools . , jQuery jQuery, addEvent. MooTools , MooTools: $== document.id $$ == document.search

document.id var , :

var $M = document.id;
$M('sendname').addEvent(...)
+1

- jquery.js $:

<script>$=function(){alert('hell');}</script>
<script src="http://code.jquery.com/jquery-1.9.0.min.js"></script>
<script>
$.noConflict();
$();
alert(jQuery.trim('  hello '));
</script>

html framework php:

<script>
function on_doc_ready()
         {jQuery(function($)
                 {$( "#sortable" ).sortable();
                  $( "#sortable" ).disableSelection();
                 }
                );
         }
function load_jquery_ui()
         {var s2=document.createElement('scr'+'ipt');
          s2.setAttribute('onload', 'on_doc_ready();');
          s2.src='/app/idm/statics/jQuery/js/jquery-ui-1.10.0.custom.min.js';
          document.getElementsByTagName('head')[0].appendChild(s2);
         }
function load_jquery_after_mootools()
         {var s1=document.createElement('scr'+'ipt');
          s1.src='/app/idm/statics/jQuery/js/jquery-1.9.0.js';
          s1.setAttribute('onload', '$.noConflict();load_jquery_ui();');
          document.getElementsByTagName('head')[0].appendChild(s1);
         }
load_jquery_after_mootools();
<script>
0

All Articles