如何在一个页面索引中使用多个jquery版本

时间:2013-12-02 23:28:09

标签: javascript jquery html css

是否可以处理同一页面中加载的两个jQuery版本之间的冲突? (自动完成)卡住了。假设这些代码行:

<head>
<script type='text/javascript' src='../wp-includes/js/jquery/jquery-1.9.1.js?ver=1.9.1'></script>
<script type="text/javascript">var lama = $.noConflict(true);</script>
<script type='text/javascript' src='../wp-includes/js/jquery/jquery-migrate.min1576.js?ver=1.2.1'></script>
            <script src="jquery-1.9.js"></script>
            <script type="text/javascript">
            var baru = $.noConflict(true);
            </script>
            <script src="ui/jquery.ui.core.js"></script>
         <script>
            var variabel;
            var id=1;

            function autoComplete(obj)
                {
                        $(obj).autocomplete(
                        {
                            source: function(request, response) {
                              $.ajax({
                                url: "dcoding.php",
                                type: "post",
                                dataType: "json",
                                data: {
                                  q: $(obj).val()           
                                },
                                success: function(data) {
                                response(data);
                                }
                              })
                            },
                            select: function( event, ui ) {
                         $('.auto').last().val(ui.item.nama_bahan);
                         var image = '<img src="../bahan/image/'+ui.item.photo_bahan+'" width="50" height="50">';
                          var satuan = ui.item.satuan;
                          $('.inputBahan:last').find('td').first().val(ui.item.nama_bahan);
                          $('.inputBahan:last').find('input').last().val(ui.item.satuan);
                          $('.inputBahan:last').find('td').last().append(image);
                         return false;                
                            },
                            minLength: 2,
                            delay:10,
                            matchSubset:1,
                            matchContains:1,
                            cacheLength:10,
                            autoFill:true


                        }).data( "uiAutocomplete" )._renderItem = function( ul, item ) 
                        { return $( "<li></li>" ) .data( "item.uiAutocomplete", item ) .append( "<a>" + item.nama_bahan + "</a>" ) .appendTo( ul ); };
                }

        </script>
        </head>
        <body>
        <form name="form1">
        <div style="width: 100%; margin: 0 auto; clear: both;">
          <div align="left">

          <table border="1">
          <tr>
            <td>bahan</td>
            <td>takaran</td>
            <td>satuan</td>
            <td>photo</td>
          </tr>
          <tr class="inputBahan">
            <td><input id="1" type="text" class="auto" onClick="autoComplete(this)"><label for="tags"></label></td>
            <td><input name="takaran" type="text" id="t1" class="takaran" size="7"></td>
            <td><input type"text" size="5"></td>
            <td>&nbsp;</td>
          </tr>
          <tr>
              <td>&nbsp;</td>
            <td><input type="button" name="add" id="add" value="Add"></td>
            <td><input type="button" name="remove" id="remove" value="remove"></td>
            <td><input type="button" name="submit" id="submit" value="submit"></td>

          </tr>
        </table>
        </div>
        </div>
        </form>     
        </body>

自动完成js卡住了模板js。请帮帮我。 。

0 个答案:

没有答案