JQuery Confilct - PullRequest
       2

JQuery Confilct

0 голосов
/ 03 января 2012

У меня странная ситуация, когда два JQueries конфликтуют.

Вот коды:

Первый код:

Этот код используется для создания списка дерева вСлева от страницы и измените некоторые части страницы

<script type="text/javascript">

    $(document).ready(function() {
        $("#generate").click(function() {
            var texts = [];
            $("form label").each(function() {
                var oLabel = $(this);
                var oInput = oLabel.next();
                if(oLabel.val() == "Best Regards,")
                {
                    alert(oInput.val());
                    texts.push(oLabel.text());
                    texts.push(oInput.val());
                }
                else
                    texts.push(oLabel.text() + " " + oInput.val());
            });
                texts[0] += " " + texts[1];
                texts[1] = texts[2] + " " + texts[3];
                for(i=4;i<texts.length;i++)
                    texts[i-2] = texts[i];
                texts[texts.length-2] = texts[texts.length-3];
                texts[texts.length-3] = $("#agent").val() ;
                texts[texts.length-1] = null;
            $("#cont").fadeOut('fast').hide();
            $("#fe_text").html(texts.join("\n"));
            $("#template").css('visibility','visible');
            $("#template").fadeIn('slow').show();

        });
    });
</script>

Второй код:

Этот код используется для копирования определенного <textarea> в буфер обмена

<script type="text/javascript" src="swf/ZeroClipboard.js"></script>
<script language="JavaScript">
    var clip = null;
    try
    {
    function $(id) { return document.getElementById(id); }
    }
    catch(e)
    {
        alert(e);
    }
    function init() {
        clip = new ZeroClipboard.Client();
        clip.setHandCursor( true );

        clip.addEventListener('load', function (client) {
            debugstr("Flash movie loaded and ready.");
        });

        clip.addEventListener('mouseOver', function (client) {
            // update the text on mouse over
            clip.setText( $('fe_text').value );
        });

        clip.addEventListener('complete', function (client, text) {
            debugstr("Copied text to clipboard: " + text );
        });

        clip.glue( 'd_clip_button', 'd_clip_container' );
    }

    function debugstr(msg) {
        var p = document.createElement('p');
        p.innerHTML = msg;
        $('d_debug').appendChild(p);
    }
</script>

и вот ошибка (с помощью Google Chrome JS Console).

Uncaught TypeError: Cannot call method 'treeview' of null
  (anonymous function)template2.php:17
  c.extend.readyjquery-1.4.min.js:314
  Mjquery-1.4.min.js:483
template2.php:91Uncaught TypeError: Cannot call method 'hide' of null
  (anonymous function)template2.php:91
  onload

Я надеюсь, что кто-нибудь может мне помочь с этим.

1 Ответ

4 голосов
/ 03 января 2012

Вы заменяете функцию jQuery $.
Не делайте этого.Вместо этого используйте jQuery.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...