Javascript / Jquery文件组合

时间:2016-12-07 08:00:44

标签: javascript jquery

我正在尝试包含这段代码:

;(function($) {

   'use strict'
   
   var ajaxContactForm = function() {
      // http://www.bitrepository.com/a-simple-ajax-contact-form-with-php-validation.html
      $('.contact-form').each(function() {
         var $this = $(this); 
         $this.submit(function() {
            var str = $this.serialize();
            $.ajax({
               type: "POST",
               url:  $this.attr('action'),
               data: str,
               success: function(msg) {
                  // Message Sent? Show the 'Thank You' message and hide the form
                  var result;
                  if(msg == 'OK') {
                     result = '<div class="notification_ok">Thank you! Your message has been sent!</div>';
                  } else {
                     result = msg;
                  }
                  result = '<div class="result">' + result + '</div>';
                  $this.find('.note').html(result);
               }
            });
            return false;
         }); // submit

      }); // each contactform
   }; // contact

   // Dom Ready
   $(function() {
      ajaxContactForm();
     
      
      // Initialize responsive menu
      ResponsiveMenu.initial($(window).width());
      $(window).resize(function() {
         ResponsiveMenu.menuWidthDetect($(this).width());
      });

      // Detect elements into viewport
      $('[data-waypoint-active="yes"]').waypoint(function() {
         $(this).trigger('on-appear');
      }, { offset: '90%' });

      $(window).on('load', function() {
         setTimeout(function() {
            $.waypoints('refresh');
         }, 100);
      });
   });

})(jQuery);

进入此文件: http://rocketgram.co/js/custom.js

然而,每当我尝试将两者正确合并(或者我的想法)时,我只能同时使用一个或另一个。不是都。任何人都可以分享这些冲突的原因吗?

以下是两个参考链接,它们都是单独工作的: rocketgram.co/mainjs.html rocketgram.co/customjs.html

这是上面剪切的文件: rocketgram.co/js/main.js

0 个答案:

没有答案