Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将一些Jquery代码转换为Mootools_Javascript_Jquery_Mootools - Fatal编程技术网

Javascript 将一些Jquery代码转换为Mootools

Javascript 将一些Jquery代码转换为Mootools,javascript,jquery,mootools,Javascript,Jquery,Mootools,该代码用于GoogleMapsAPI自动完成搜索地址。我必须转换它,因为在我的joomla网站冲突。我如何使用Mootools 1.4实现同样的功能?我们将非常感谢您的帮助 代码如下: $(document).ready(function() { initialize(); $(function() { $("#entry_3").autocomplete({ //This bit uses the geocoder to fetch address value

该代码用于GoogleMapsAPI自动完成搜索地址。我必须转换它,因为在我的joomla网站冲突。我如何使用Mootools 1.4实现同样的功能?我们将非常感谢您的帮助

代码如下:

$(document).ready(function() { 

  initialize();

  $(function() {
    $("#entry_3").autocomplete({
      //This bit uses the geocoder to fetch address values
      source: function(request, response) {
        geocoder.geocode( {'address': request.term }, function(results, status) {
          response($.map(results, function(item) {
            return {
              label:  item.formatted_address,
              value: item.formatted_address,
              latitude: item.geometry.location.lat(),
              longitude: item.geometry.location.lng()
            }
          }));
        })
      },
      //This bit is executed upon selection of an address
      select: function(event, ui) {
        $("#entry_4").val(ui.item.latitude);
        $("#entry_5").val(ui.item.longitude);
        var location = new google.maps.LatLng(ui.item.latitude, ui.item.longitude);
        marker.setPosition(location);
        map.setCenter(location);
      }
    });
  });
});
编辑:
添加window.onunload=GUnload是错误的;在谷歌地图api v3中。这是一个v2函数。v3不需要onunload。这就搞乱了自动完成功能。

您不需要用mootools编写代码,只需使用 jquery没有冲突

jQuery.noConflict();
     jQuery(document).ready(function($){
       // you're jquery code

     });

冲突是因为您使用jQuery和Mootools吗?如果是这样,您在尝试执行这种规模的操作之前是否尝试过使用jQuery.noConflict()?如果存在冲突,请使用“CNTRL+F”并将“$”的所有实例替换为“jQuery”“我尝试过,但没有结果。您收到的错误是什么?了解jQuery.noConflict()的用法;这是一件大事。此页面上有一个答案,其中有一个指向此问题文档的链接。让我知道,如果您在确保“正确操作”后仍保留问题,该死,我忘记删除一个不在适当位置的window.onunload事件。。。一切都好了!谢谢问题不在jQuery.noConflict()中,毕竟:-)我喜欢它。很高兴听到你让它工作了。介意在你的帖子中创建一个“编辑”并显示问题所在的位置吗?这样,从未来来到这里的任何人都可以快速了解问题所在,并将他们的问题与你的问题进行比较,看看他们是否需要相同的解决方案?谢谢,祝你好运!