2

I have two differnt jquery scripts that both work on their own, but when I try to combine then on same page, they break. I notice they call different versions of jquery, but if I try to use one or the other, it breaks one of the functions.. Anyone help me know why?

First script:

<head>
<link rel="stylesheet"href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"/>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="ajax.js"language="javascript"type="text/javascript"></script>
<script>
  $(function() {
    var availableTags = [
    "Abel Law Offices",
    "Abigail Rivamonte, Attorney at Law",
    "Abrams & Heyn"
    ];
    $( "#tags").autocomplete({
      source: availableTags
    });
  });
 </script>
</head>

<body>
<input type="text" id="tags" name="tags" >
</body>
</html>

Second script:

<script src="http://code.jquery.com/jquery-1.4.2.min.js" type="text/javascript"></script>
<script>
            $(document).ready(function () {
                $("#checkbox_1").change(function () {
                    $("#tags").attr("disabled", $(this).attr("checked"));
                });
            });
</script>

What is the issue here? Thank you in advance.

What I want is a suggested field box, and a check box that disables the suggested field box when clicked. Ive done both on their own before, so I thought I could simply use both... But alas.

user1789437
  • 490
  • 1
  • 7
  • 22

2 Answers2

1

Use jQuery 1.9 or the latest branch only and try this line:

$("#tags").attr("disabled", $(this).prop("checked"));

instead of

$("#tags").attr("disabled", $(this).attr("checked"));

The .attr() function always gives you the originally set attribute. It's .prop() what you are looking for. That gives you the current value of the checkbox.

Do not include two different version of jQuery at the same time.

Simon Steinberger
  • 6,605
  • 5
  • 55
  • 97
-1

First, attempt to use the latest version of jQuery, so eliminate the use of 1.4.2. You might want to fix the problems.

If that doesn't work, try using jQuery.noConflict().

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445